文本到语音:语音方法不起作用

拉克希米

我尝试实现 Text To Speech,但是当我编写一个方法时,它没有正确显示语音方法。以下是我的方法代码

主活动.java

private void ConvertTextToSpeech() {
        // TODO Auto-generated method stub
        text = et.getText().toString();
        // If no text is typed, tts will read out 'You haven't typed text'
        // else it reads out the text you typed
        if (text.length() == 0) {
            tts.speak("You haven't typed text", TextToSpeech.QUEUE_FLUSH, null);
        } else {
            tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);

        }

    }

不是像上面那样显示,而是像这样显示

tts.s̶p̶e̶a̶k̶

我的 build.gradle(app) 是

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.example.Hacker.texttospeech"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

如何使它工作?我认为这是一个API问题。
我正在尝试在 API 级别 16 上实现这一点。

如果是 API 问题,如何在 API 级别 16+ 上运行它?

一个板球运动员

只需检查文档以获取正确的表格

此方法在 API 级别 21 中已弃用。

从 API 级别 21 开始,替换为 speak(CharSequence, int, Bundle, String)

如果这不起作用,那么问题出在其他地方

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Java:文本到语音引擎概述

需要文本到语音和用于Linux的语音识别工具

Android语音识别:startActivityForResult()不起作用

使用WebSockets的IBM Watson语音到文本

语音识别在Firefox中不起作用

Flutter:文本到语音数组

是否可以使“ HTML到语音”与“文本到语音”相同?

Google语音转文本:附加语言设置为“ kn”,但不起作用

'en-GB-Wavenet-C'不起作用[Google Cloud文本到语音]

Swift 4中的文本到语音转换

带有认知语音的Azure Bot框架不起作用

Azure语音到文本多语音识别

GCP语音到文本-Java API不起作用

更改SpeechSynthesis语音不起作用

在listitem单击中使用该文本时语音转换不起作用,而myactivity在Tabactivity中

如何运行简单的文本到语音命令?

非英语语言的语音到文本的转换

选定文本的文本到语音ubuntu 16.04

使用python 3.5进行语音文本到语音转换

从另一个类/控制器(IOS,目标c)获取字符串时,张开耳朵的文本到语音(语音)不起作用

Bing 文本转语音在 Android 中不起作用

Shiny Watson 实时文本到语音

Word 的文本到语音替换

当我在 android 聊天机器人中将文本作为输入进行语音转换时,我的文本转语音不起作用

文本到语音不起作用,使用语音到文本获取文本时

Twilio 可编程语音不起作用

教程语音意图识别不起作用?

语音识别语音到文本在 python 中不起作用

文本到语音 Android 工作室 - Kotlin 不起作用