Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,6 +15,24 @@ headers ={
|
|
15 |
'Ocp-Apim-Subscription-Key': demo_keys
|
16 |
}
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
def translate(text, source_language, target_language):
|
19 |
data = {
|
20 |
"in": text,
|
|
|
15 |
'Ocp-Apim-Subscription-Key': demo_keys
|
16 |
}
|
17 |
|
18 |
+
def synthesize(text, language):
|
19 |
+
data = {
|
20 |
+
"text": text,
|
21 |
+
"language": language
|
22 |
+
}
|
23 |
+
audio = requests.post(tts_url, headers=headers, json=data).content
|
24 |
+
|
25 |
+
# Write bytes to a temporary file
|
26 |
+
with tempfile.NamedTemporaryFile(delete=True) as temp_wav:
|
27 |
+
temp_wav.write(audio)
|
28 |
+
temp_wav.flush()
|
29 |
+
|
30 |
+
# Read the wav file
|
31 |
+
rate, audio_array = wavfile.read(temp_wav.name)
|
32 |
+
|
33 |
+
return (rate, audio_array)
|
34 |
+
|
35 |
+
|
36 |
def translate(text, source_language, target_language):
|
37 |
data = {
|
38 |
"in": text,
|