Update app.py
Browse files
app.py
CHANGED
@@ -36,6 +36,11 @@ head = '''
|
|
36 |
<script type="module">
|
37 |
import { matcha_tts,env } from "https://akjava.github.io/Matcha-TTS-Japanese/js-esm/v001-20240921/matcha_tts_onnx_en.js";
|
38 |
window.MatchaTTSEn = matcha_tts
|
|
|
|
|
|
|
|
|
|
|
39 |
</script>
|
40 |
'''
|
41 |
with gr.Blocks(title="LLM with TTS",head=head) as demo:
|
@@ -43,14 +48,9 @@ with gr.Blocks(title="LLM with TTS",head=head) as demo:
|
|
43 |
gr.Markdown("**gemma-2-27b-it/LJSpeech**.LLM and TTS models will change without notice.")
|
44 |
|
45 |
js = """
|
46 |
-
function replaceSpecialChars(text) {
|
47 |
-
const pattern = /[^a-zA-Z0-9,.!?-_']/g;
|
48 |
-
return text.replace(pattern, ' ');
|
49 |
-
}
|
50 |
-
|
51 |
function(chatbot){
|
52 |
text = (chatbot[chatbot.length -1])["content"]
|
53 |
-
window.MatchaTTSEn(replaceSpecialChars(text))
|
54 |
}
|
55 |
"""
|
56 |
chatbot = gr.Chatbot(type="messages")
|
|
|
36 |
<script type="module">
|
37 |
import { matcha_tts,env } from "https://akjava.github.io/Matcha-TTS-Japanese/js-esm/v001-20240921/matcha_tts_onnx_en.js";
|
38 |
window.MatchaTTSEn = matcha_tts
|
39 |
+
function replaceSpecialChars(text) {
|
40 |
+
const pattern = /[^a-zA-Z0-9,.!?-_']/g;
|
41 |
+
return text.replace(pattern, ' ');
|
42 |
+
}
|
43 |
+
window.replaceSpecialChars = replaceSpecialChars
|
44 |
</script>
|
45 |
'''
|
46 |
with gr.Blocks(title="LLM with TTS",head=head) as demo:
|
|
|
48 |
gr.Markdown("**gemma-2-27b-it/LJSpeech**.LLM and TTS models will change without notice.")
|
49 |
|
50 |
js = """
|
|
|
|
|
|
|
|
|
|
|
51 |
function(chatbot){
|
52 |
text = (chatbot[chatbot.length -1])["content"]
|
53 |
+
window.MatchaTTSEn(window.replaceSpecialChars(text))
|
54 |
}
|
55 |
"""
|
56 |
chatbot = gr.Chatbot(type="messages")
|