我发现了一个支持多种语言的语音合成器(http://espeak.sourceforge.net/index.html).但是可用的源代码是用C语言编写的.
我该怎么做才能让它在iPhone上运行?
我最近实现了一个基本的Web应用程序,该应用程序依赖于Google的TTS URL生成清晰的MP3文件,以便在前端播放。
从那以后,它就受到了额外的安全检查,这意味着我不得不更新代码库以使用替代方法。
一种此类替代方法是javascript的语音合成API,即SpeechSynthesisUtterance()和window.speechSynthesis.speak('...')。这在我的台式机和笔记本电脑上确实能很好地工作,但是一旦在iOS设备上使用它,音频的速度就会大大提高。
谁能建议我可以解决这个问题?
参见下面的示例代码:
var msg = new SpeechSynthesisUtterance();
msg.text = item.title;
msg.voice = "Google UK English Male";
msg.rate = 0.7;
msg.onend = function(){
console.log('message has ended');
$('.word-img').removeClass('img-isplaying');
};
msg.onerror = function(){
console.log('ERROR WITH SPEECH API');
$('.word-img').removeClass('img-isplaying');
};
window.speechSynthesis.speak(msg);
Run Code Online (Sandbox Code Playgroud) 我使用下面的代码使用Android内置程序合成.txt文件到.mp3文件TTS Engine.
码:
textToSpeech.synthesizeToFile(readFileText, utterParam, destinationFileName);
textToSpeech.setOnUtteranceProgressListener(new UtteranceProgressListener() {
@Override
public void onStart(final String utteranceId) {
Log.e(TAG, "onStart...");
}
@Override
public void onDone(final String utteranceId) {
Log.e(TAG, "onDone...");
}
@Override
public void onError(String utteranceId) {
Log.e(TAG, "onError...");
}
});
Run Code Online (Sandbox Code Playgroud)
以上是示例代码.以下是应用程序执行流程:
问题:文件合成完成后,我只能播放mp3文件.对于大小为1 mb的文件,大约需要1分钟.
我可以做些什么改进吗?
注意:我们需要使用MediaPlayer我们需要播放/暂停阅读器.
谢谢.
android text-to-speech speech-synthesis google-text-to-speech
我想用许多语言的许多声音进行文本到语音转换.
我试过SpeechSynthesizer(Ref:System.Speech),但它只允许2个英语语音.从微软网站安装6个英语语音后,我仍然无法获得任何其他声音.
我改为SpVoice(参考:微软语音对象库).SpVoice可识别我刚安装的6种声音.问题是当我打电话时spVoice.Pause(),它总是会在完全停止说话之前延迟0.5秒.我也尝试AlertBoundary为SpVoice 设置,但它没有帮助.
SpeechSynthesizer可以立即暂停,SpeakAsyncCancelAll但仅适用于默认语音.
我正在尝试使用speechSynthesis http://blog.teamtreehouse.com/getting-started-speech-synthesis-api
首先,我使用界面扩展了窗口:
window.interface.ts
export interface IWindow extends Window {
webkitSpeechRecognition: any;
speechSynthesis: any;
}
Run Code Online (Sandbox Code Playgroud)
接下来我做了一个窗口服务:
window.service.ts
import { Injectable } from '@angular/core';
import { IWindow } from '../interfaces/window-interface';
function _window() : IWindow {
return window;
}
@Injectable()
export class WindowService {
get nativeWindow() : any {
return _window();
}
}
Run Code Online (Sandbox Code Playgroud)
现在在组件中,我正在尝试实现它......没有成功..
app.component
import { Component, OnInit, ViewChild } from '@angular/core';
import { WindowService } from '../../providers/window.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['.app.component.scss']
})
export class AppComponent implements OnInit …Run Code Online (Sandbox Code Playgroud) 我正在开发一个应用程序,要求我在Web浏览器中使用文本到语音.我正在使用HTML5语音合成.在谷歌浏览器上,代码运行正常,所有可用的声音都使用| getVoices()|列出,但在Firefox中根本没有列出语音.我在Firefox 56.0(Ubuntu)上测试我的代码.
在通过互联网搜索时,我确实遇到了一个StackOverflow 答案,该答案表明应该在| onVoiceChanged |之后调用getVoices()函数.事件
window.speechSynthesis.onvoiceschanged = function() {
window.speechSynthesis.getVoices();
...
};
Run Code Online (Sandbox Code Playgroud)
我正在以上述方式调用该呼叫,它在Chrome中可以正常工作,但在Firefox上则不行.
另一个StackOverflow回答建议我启用| media.webspeech.synth.enabled | 在about:配置Firefox,但在我的Firefox中首选| media.webspeech.synth.enabled | 已经设置为true.
我查看了MDN文档https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis/getVoices,此页面上的示例在Firefox中没有运行,但在Chrome中运行良好.我发现CanIUse.com列出了Firefox 55以后支持的SpeechSynthesis,但它对我不起作用.
还演示由Mozilla开发者网络来演示语音合成失败对我的Firefox浏览器,但在谷歌浏览器运行正常.我在网上广泛搜索了一个解决方案,但找不到一个.有人可以在这里指出我正确的方向.
所以我用事件示例尝试了MSAPI 5.4 TTS。现在我创建了一个使用 SetNotifyCallbackFunction 的 cmd 提示应用程序,但我传递的函数没有被调用。我不是 C++ 专家,所以我在解决这个问题时遇到了困难,谁能指出我正确的方向,或者至少给我一个 SetNotifyCallbackFunction 的好例子?
这是我的代码的简化版本:
typedef void __stdcall SPNOTIFYCALLBACK(WPARAM wParam, LPARAM lParam);
void __stdcall outsideeventFunction(WPARAM, LPARAM);
void __stdcall outsideeventFunction(WPARAM wParam, LPARAM lParam){
std::cout << "Event called::wParam: " << wParam << " lParam: " << lParam << std::endl;
SPEVENT eventItem;
memset(&eventItem, 0, sizeof(SPEVENT));
while (SUCCEEDED(pV->GetEvents(1, &eventItem, NULL)))
{
bool exitNa = false;
switch (eventItem.eEventId)
{
case SPEI_WORD_BOUNDARY:
SPVOICESTATUS eventStatus;
pV->GetStatus(&eventStatus, NULL);
ULONG start, end;
start = eventStatus.ulInputWordPos;
end = eventStatus.ulInputWordLen; …Run Code Online (Sandbox Code Playgroud) 我需要预处理强制对齐的语音记录.但是,我用文本表示替换年份有困难.例如,1984年需要被"1984年"取代.我尝试了qdap包的replace_number函数.包装很棒,但它取而代之的是1984年的"一千九百八十四".我可以尝试任何R包中的其他功能吗?谢谢!
这段代码正在运行,但我只能在Microsoft Windows中预先安装的声音之间切换.这些声音是"Microsoft David Mobile"和"Microsoft Zira Mobile".
后来我安装了"Microsoft Kalpana Mobile"并将其设置为默认的Windows语音.但我仍然无法切换到"Microsoft Kalpana Mobile".代码是 -
import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id) #changing index changes voices but ony 0 and 1 are working here
engine.say('Hello World')
engine.runAndWait()
Run Code Online (Sandbox Code Playgroud)
只有0和1作为声音[]内的索引.
我想要"微软Kalpana Mobile"发言.我在这个项目上工作了2个月.如果这不起作用,我所有的努力都将继续下去.请帮忙:(
提前致谢.