Closed LuekWasHere closed 1 year ago
Custom HTTP
TTS is deprecated, you can use the more powerful JavaScript plugin functionality.
This is an example of Baidu TTS plugin if you have any doubts, please ask questions.
You can modify the HTTP request parameters according to your needs :
let reqParams = `?voice=larynx%3Acmu_aew-glow_tts&text=${encText}&vocoder=low&denoiserStrength=0&cache=true`
Full plugin code:
Add Plugin -> replace code -> Save -> Enable OpenTTS
let PluginJS = { 'name': 'OpenTTS', 'id': 'opentts.com', 'author': 'TTS Server', 'version': 1,
'getAudio': function(text,locale, voice, speed, volume, pitch) {
let encText = encodeURIComponent(text)
let reqParams = ?voice=larynx%3Acmu_aew-glow_tts&text=${encText}&vocoder=low&denoiserStrength=0&cache=true
// make request to TTS API
let reqUrl = 'http://192.168.0.226:5500/api/tts' + reqParams
let reqHeaders = {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
}
return ttsrv.httpGet(reqUrl, reqHeaders).body().byteStream()
}
}
let locales = ['en'] let voices = { 'en': { '1': 'voice1', } }
let EditorJS = { 'getAudioSampleRate': function(locale, voice) { let audio = PluginJS.getAudio('sampletext', 'en', voice, 50, 50, 50) return ttsrv.getAudioSampleRate(audio) },
'onLoadData': function() {
},
'getLocales': function() {
return locales
},
'getVoices': function(locale) {
return voices[locale]
},
'onLoadUI': function(ctx, linearLayout) {
}
}
哇,你的帮助让我感到震惊。我非常感激。我可以保证这个工作很好,我现在有一个离线TTS,它的工作效果非常好。我真的很喜欢学习新东西,你做得很好,让我受益匪浅。我将想办法将Opentts api纳入其他方面(例如能够更改语音),以及在树莓派或其他可持续性设备上运行TTS服务器。你太棒了。
Hello I unfortunately don't speak Chinese so this language barrier might make communication difficult, I will do my best to communicate clearly. I am attempting to make a custom http request using the tts-server-android application. Im running a Opentts server which allows me to run a neural net tts offline and make https requests to it. The tts is excellent. It works somewhat well with your application. Though it seems during the encoding of the text from your tts app it seems to have a syntax conflict with the actual raw text (causing the text to be parsed incorrectly).
翻译 您好,我不会说中文,所以语言障碍可能会使沟通变得困难,但我会尽力清晰地表达。我正在尝试使用 tts-server-android 应用程序进行自定义 http 请求。我正在运行一个 Opentts 服务器,它允许我离线运行一个神经网络 tts 并对其进行 https 请求。这个 tts 非常出色。它与您的应用程序配合得相当好。不过,在您的 tts 应用程序对文本进行编码时似乎与实际的原始文本存在语法冲突(导致文本解析不正确)。
// Example of failure from log 日志中失败的示例:
<br>Request audio: <b>from an intelligence explosion (Good 1965): a process in which software based intelligent minds enter a runaway reaction of self improvement cycles, with each new and more intelligent generation appearing faster than its predecessor.</b><br> <i><small>HttpTTS(url=http://192.168.0.226:5500/api/tts?voice=larynx%3Acmu_aew-glow_tts&text={{java.encodeURI(speakText)}}&vocoder=low&denoiserStrength=0&cache=true , header=, pitch=1, volume=50, rate=0, audioFormat=16000hz | decode, audioPlayer=PlayerParams(rate=0.0, pitch=0.0, volume=0.0), audioParams=AudioParams(speed=2.13, volume=1.0, pitch=1.19), speechRule=SpeechRuleInfo(target=0, isStandby=false, tag=, tagRuleId=, tagName=, tagData={}, configId=1689134740002))</small></i>
has a log output of 具有日志输出:
Failed: (1) cc.l: Expected start of the object '{', but had 'EOF' instead at path: $ JSON input: %20with%20each%20new%20and%20more%20intelligent%20generation%20appearing%20faster%20than%20its%20predecessor.&vocoder=low&denoiserStrength=0&cache=true
// Example of successful parse from log 日志中成功解析的示例:
<br>Request audio: <b>Part I of this volume is dedicated to essays which argue that progress in artificial intelligence and machine learning may indeed increase machine intelligence beyond that of any human being.</b><br> <i><small>HttpTTS(url=http://192.168.0.226:5500/api/tts?voice=larynx%3Acmu_aew-glow_tts&text={{java.encodeURI(speakText)}}&vocoder=low&denoiserStrength=0&cache=true , header=, pitch=1, volume=50, rate=0, audioFormat=16000hz | decode, audioPlayer=PlayerParams(rate=0.0, pitch=0.0, volume=0.0), audioParams=AudioParams(speed=2.13, volume=1.0, pitch=1.19), speechRule=SpeechRuleInfo(target=0, isStandby=false, tag=, tagRuleId=, tagName=, tagData={}, configId=1689134740002))</small></i>
I hope this makes sense. I've tried changing the url in many ways. Though these still seems to be a conflict with only specific raw texts. If you have any ideas on how i could change this url input to avoid the conflict with the raw text, please let me know. 我希望这能讲得通。我尝试过以多种方式更改 url。不过,似乎仍然只有特定的原始文本存在冲突。 如果您有任何关于如何更改此 url 输入以避免与原始文本冲突的想法,请告诉我。
Thank you 谢谢, Lewk