Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import gradio as gr
|
3 |
+
import base64
|
4 |
+
|
5 |
+
def synthesize(key, sentence, speaker):
|
6 |
+
headers = {
|
7 |
+
'Authorization': 'Bearer {}'.format(key),
|
8 |
+
'Content-Type': 'application/json',
|
9 |
+
}
|
10 |
+
|
11 |
+
json_data = {
|
12 |
+
'text': sentence,
|
13 |
+
'speaker': speaker,
|
14 |
+
}
|
15 |
+
|
16 |
+
response = requests.post('https://rjmopratfrdjgmfmaios.functions.supabase.co/rime-tts', headers=headers, json=json_data)
|
17 |
+
audioContent = response.json()['audioContent']
|
18 |
+
decode_string = base64.b64decode(audioContent)
|
19 |
+
with open('tmp.wav', 'w') as fp:
|
20 |
+
fp.write(decode_string)
|
21 |
+
return 'tmp.wav'
|
22 |
+
|
23 |
+
iface = gr.Interface(fn=synthesize, inputs="text", inputs="text", outputs=gr.Audio())
|
24 |
+
iface.launch()
|