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()