acity-Demo / app.py
Lagyamfi's picture
Create app.py
0565a93 verified
raw
history blame
967 Bytes
import gradio as gr
import requests
import os
import tempfile
from scipy.io import wavfile
demo_keys = os.environ['DEMO_KEYS']
tts_url = "https://translation-api.ghananlp.org/tts/v1/tts"
translation_url = "https://translation-api.ghananlp.org/v1/translate"
headers ={
# Request headers
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
'Ocp-Apim-Subscription-Key': demo_keys
}
def translate(text, source_language, target_language):
data = {
"in": text,
"lang": source_language + "-" + target_language
}
response = requests.post(translation_url, headers=headers, json=data).text
return response
gr.Interface(
fn=synthesize,
inputs=[
gr.Text(label="Input Text"),
gr.Radio(label="Language", choices=[
"tw",
],
value="tw"),
],
outputs=[
gr.Audio(label="Generated Speech", type="numpy"),
],
title="ACity TTS Demo",
).launch()