我正在尝试为Android实现TTS应用程序。这是我到目前为止编写的代码:
import android.app.Activity;
import android.content.Intent;
import android.view.View.OnClickListener;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.Locale;
public class AlarmActivity extends Activity implements OnClickListener, TextToSpeech.OnInitListener {
private TextToSpeech mTts;
private static final String TAG = "TextToSpeechDemo";
private static final int MY_DATA_CHECK_CODE = 1234;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.alarm);
Button btnAdd = (Button) findViewById(R.id.btnAdd);
btnAdd.setOnClickListener(this);
btnAdd.setEnabled(false);
TextView txt = (TextView) findViewById(R.id.txt);
txt.setText("OnCreate");
// Fire off an intent to check if a TTS engine is …Run Code Online (Sandbox Code Playgroud) 我将创建一个文本到语音转换器,它可以在Windows和基于Linux的系统中执行.有人可以帮我回答以下问题;
请分享您的经验.
在土耳其语中是否有针对Android的免费TTS(文本到语音)服务?我在google中找不到任何有用的东西.
继在提示这个答案,我放在一个电话setEngineByPackageName权onActivityResult(),当requestCode == REQ_TTS_STATUS_CHECK && TextToSpeech.Engine.CHECK_VOICE_DATA_PASS:
tts = new TextToSpeech(this, this);
tts.setEngineByPackageName("com.ivona.tts.voicebeta.eng.usa.kendra");
Run Code Online (Sandbox Code Playgroud)
但无论是检查还是取消选中Always use my settings文本到语音设置,我总是得到pico默认引擎!
是的,我故意将微微引擎设置为默认值,以便我可以通过上述提示测试覆盖它.但是那种API方法似乎根本不起作用,或者......我错过了什么?
(我知道setEngineByPackageName已被弃用,因为它在初始化TTS引擎时不通知调用者,但我需要支持API 8,所以此方法是我目前的唯一选择)
我正在制作一个单击它时读取句子的应用程序,所以我使用TTS来阅读它们.问题是语音不是那么清楚,有没有办法改变它?或者让它读得慢一些?
如何减慢"Say"动词中的正常内容?西班牙语的口音非常快,大多数人都无法理解所说的内容.理想情况下,以下内容将是完美的:
<Say voice="woman" language="es" speed="0.5">El siguiente mensaje se repetirá en español</Say>
Run Code Online (Sandbox Code Playgroud)
注意我编写了speed ="0.5"参数.对于twilio来说,这不是一个选项,但是将"Say"动词内容的读取速度降低一半是我正在寻找的.
我认为目前没有任何明确的方式支持这一点,所以也欢迎关于如何实现更多hackish的想法.文字是动态的.
感谢您的见解.
我在我的iOS应用程序中使用AVSpeechSynthesizer for TTS.但是没有调用didFinishSpeechUtterance方法.
这是我在.h中的代码:
#import <AVFoundation/AVFoundation.h>
@interface EmailViewController : UIViewController <UITextFieldDelegate, AVSpeechSynthesizerDelegate>
@property (nonatomic, strong) AVSpeechSynthesizer* talker;
Run Code Online (Sandbox Code Playgroud)
这是在.m
- (void) startTalking {
NSString *hi = [NSString stringWithFormat:@"%@", humanLanguageArray[speaknumber]];
AVSpeechUtterance* utter = [[AVSpeechUtterance alloc] initWithString:hi];
utter.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
[utter setRate:0.2f];
if (!self.talker) {
self.talker = [AVSpeechSynthesizer new];
}
self.talker.delegate = self;
[self.talker speakUtterance:utter];
}
- (void)stopSpeech
{
AVSpeechSynthesizer *talked = [[AVSpeechSynthesizer alloc] init];
if([talked isSpeaking]) {
[talked stopSpeakingAtBoundary:AVSpeechBoundaryImmediate];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@""];
[talked speakUtterance:utterance];
[talked stopSpeakingAtBoundary:AVSpeechBoundaryImmediate];
}
}
- …Run Code Online (Sandbox Code Playgroud) 我一直在使用python 3.4的gTTS模块来制作口语文本的mp3文件.它一直在工作,但所有的演讲都是在某个成年女性的声音中.有没有办法自定义gTTS读取文本的语音?
我致力于语音识别.我用IOS框架解决了文本到语音和语音到文本的问题.但现在我想将保存的音频文件对话转换为文本.我怎么解决这个问题?谢谢你的回复.
目前,我已经实现了文字转语音(TTS)来阅读书籍。由于TTS最多只能容纳4000个字符(而且一本书的数量更多),所以我将本书拆分开,并将每个部分添加到TTS队列中。我希望能够单击一个按钮并暂停TTS,然后再从用户停止的地方继续执行TTS。
我尝试使用synthesizeToFile并暂停媒体文件对象,但是同样,您一次只能合成一个文件,少于4000个字符。我不想仅在TTS上将数百个媒体文件存储在用户设备上。
我可以让TTS读这本书,只是停下来不停然后从书的开头开始TTS。
在下面的代码中,我将整本书存储在string中bookText。TTS引擎是tts变量。
这是我加载TTS队列的方式:
int position = 0;
int pos = 0;
int sizeOfChar = bookText.length();
String testString = bookText.substring(position,sizeOfChar);
int next = 500;
while(true) {
String temp = "";
try {
temp = testString.substring(pos, next);
HashMap<String, String> params = new HashMap<String, String>();
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, temp);
tts.speak(temp, TextToSpeech.QUEUE_ADD, params);
pos = pos + 500;
next = next + 500;
}
catch (Exception e) {
temp = testString.substring(pos, testString.length());
tts.speak(temp, TextToSpeech.QUEUE_ADD, null);
break;
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我“停止” TTS的方式: …