在向TTS引擎发送请求时,有没有办法控制TTS引擎的音量?我可以在这里使用AudioManager吗?
谢谢.
我有一个php和jquery的项目.我需要做的最后一件事是,当用户点击按钮时,作为文本的用户名称,pc将文本名称转换为声音并播放到pc扬声器.有任何类或插件可以帮助做到这一点?谢谢
我有一个应用程序在启动时使用文本转语音.一切似乎都很完美,我在运行应用程序时没有任何问题.但是,每次应用程序启动时,我都会收到一条LogCat错误,指出我的文本转语音出现了泄漏的ServiceConnection.虽然这不会导致功能问题,但我担心如果我继续忽略错误,将来会发生什么.我怀疑这只是错误的编码,但我没有经验来确定错位.我已经包含了LogCat和令人讨厌的java.
07-31 10:16:50.812: E/ActivityThread(27785): Activity com.example.com.proto1.menu has leaked ServiceConnection android.speech.tts.TextToSpeech$1@40d68398 that was originally bound here
07-31 10:16:50.812: E/ActivityThread(27785): android.app.ServiceConnectionLeaked: Activity com.example.com.proto1.menu has leaked ServiceConnection android.speech.tts.TextToSpeech$1@40d68398 that was originally bound here
07-31 10:16:50.812: E/ActivityThread(27785): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:932)
07-31 10:16:50.812: E/ActivityThread(27785): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:827)
07-31 10:16:50.812: E/ActivityThread(27785): at android.app.ContextImpl.bindService(ContextImpl.java:1109)
07-31 10:16:50.812: E/ActivityThread(27785): at android.content.ContextWrapper.bindService(ContextWrapper.java:370)
07-31 10:16:50.812: E/ActivityThread(27785): at android.speech.tts.TextToSpeech.initTts(TextToSpeech.java:517)
07-31 10:16:50.812: E/ActivityThread(27785): at android.speech.tts.TextToSpeech.<init>(TextToSpeech.java:483)
07-31 10:16:50.812: E/ActivityThread(27785): at com.example.com.proto1.menu.onActivityResult(menu.java:255)
07-31 10:16:50.812: E/ActivityThread(27785): at android.app.Activity.dispatchActivityResult(Activity.java:4581)
07-31 10:16:50.812: E/ActivityThread(27785): at android.app.ActivityThread.deliverResults(ActivityThread.java:2817)
07-31 10:16:50.812: E/ActivityThread(27785): at android.app.ActivityThread.handleSendResult(ActivityThread.java:2864) …Run Code Online (Sandbox Code Playgroud) 我使用以下代码将Text to Speech输出存储为我的应用程序中的wav文件.我不确定错误在哪里,你能看一下并建议我吗?
public class MainActivity extends Activity {
Button store, play;
EditText input;
String speakTextTxt;
TextToSpeech mTts;
HashMap<String, String> myHashRender = new HashMap<String, String>();
String tempDestFile ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
store = (Button) findViewById(R.id.button1);
play = (Button) findViewById(R.id.button2);
input = (EditText) findViewById(R.id.editText1);
store.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
speakTextTxt = "Hello world Hello world Hello world Hello world Hello world Hello world Hello world Hello world Hello world …Run Code Online (Sandbox Code Playgroud) 我试图使用SpeakAsync()方法来说一些文字.但是,在我调用Speak()之前,它不会开始说话.我不想打电话给Speak().如果从此代码中删除Speak()方法,则根本不会调用任何内容:
using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
synth.SelectVoice("ScanSoft Emily_Dri20_22kHz");
synth.Rate = 10;
synth.Volume = 100;
synth.SpeakAsync("oh, i'm a lumberjack and i'm okay! I sleep all night and I work all day!");
synth.SpeakAsync("If he was dying he wouldn't bother writing ah! He'd just say it!");
synth.Speak("i don't want to go on the cart.");
synth.SpeakAsync("We don't have a lord. We're an anarcho-syndicalist commune.");
synth.SpeakAsync("If you do not show us the grail, we shall take your castle by force!");
synth.Speak("what do you …Run Code Online (Sandbox Code Playgroud) 我申请文本到语音到我的应用程序(如图所示的程序在这里).它在大多数设备上完美运行.但在某些设备中LG Optimus G, GK, L3 II and Sky IM-A800S,应用程序活动意外停止,并出现以下错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.appname/com.myapp.appname.ContentView}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.speech.tts.engine.CHECK_TTS_DATA }
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2067)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
at android.app.ActivityThread.access$600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4827)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.speech.tts.engine.CHECK_TTS_DATA }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1568)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1439)
at android.app.Activity.startActivityForResult(Activity.java:3351)
at android.app.Activity.startActivityForResult(Activity.java:3312)
at android.support.v4.app.FragmentActivity.startActivityForResult(Unknown Source)
at viettien.kadict.ContentView.onCreate(Unknown …Run Code Online (Sandbox Code Playgroud) 我的应用程序包含两个字符串和两个按钮,一个英文字符串和印地语字符串,当我点击英语发言按钮时,英语字符串发音,当我来到印地语字符串时,它没有响应给定的单词,因为它被提及.
这是我的MainActivity外观,
public class MainActivity extends AppCompatActivity {
private TextView englishString, hindiString;
private Button englishButton, hindiButton;
private TextToSpeech textToSpeech;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
englishString = (TextView) findViewById(R.id.englishString);
hindiString = (TextView) findViewById(R.id.hindiString);
englishButton = (Button) findViewById(R.id.englishButton);
hindiButton = (Button) findViewById(R.id.hindiButton);
englishButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
loadSpeakingLanguages(englishString.getText().toString());
}
});
hindiButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
loadSpeakingLanguages(hindiString.getText().toString());
}
});
}
private void loadSpeakingLanguages(String textToTranslate) {
if …Run Code Online (Sandbox Code Playgroud) 我需要预处理强制对齐的语音记录.但是,我用文本表示替换年份有困难.例如,1984年需要被"1984年"取代.我尝试了qdap包的replace_number函数.包装很棒,但它取而代之的是1984年的"一千九百八十四".我可以尝试任何R包中的其他功能吗?谢谢!
我有一个项目,我正在进行文本到语音转换.我的音频文件存储为mp3.
但现在,当我检查Gtts api时抛出错误.我试过搜索但找不到可行的解决方案.
我的代码如下:
def synth(sent,language='en',slow = False):
"""
Synthesize text into audio
"""
os.system('clear')
print("Speaker Output:" + sent)
gt_ob = gTTS(text=sent, lang=language, slow=slow)
file_name = hashlib.md5(sent.encode('utf-8')).hexdigest()
print("File Name " + file_name)
gt_ob.save("media/audio.mp3")
print("Till here")
os.system("ffmpeg -nostats -loglevel 0 -y -i media/audio.mp3 -ar 16000 media/"+ file_name + ".wav")
if __name__ == "__main__":
synth("good morning","en")
Run Code Online (Sandbox Code Playgroud)
我得到的错误消息是:
File "file_name.py", line 30, in <module>
synth("good morning","en")
File "file_name.py", line 25, in synth
gt_ob.save("media/audio.mp3")
File "/home/arqam/anaconda3/lib/python3.6/site-packages/gtts/tts.py", line 247, in save
self.write_to_fp(f)
File "/home/arqam/anaconda3/lib/python3.6/site-packages/gtts/tts.py", line …Run Code Online (Sandbox Code Playgroud)