tts / app.py
ronniet's picture
Update app.py
989f593
raw
history blame
1.95 kB
import gradio as gr
from TTS.api import TTS
tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=False)
def predict(text):
file_path = "output.wav"
tts.tts_to_file(text, speaker=tts.speakers[0], language="en", file_path=file_path)
return file_path
demo = gr.Interface(
fn=predict,
inputs='text',
outputs='audio'
)
demo.launch()
# import requests
# import time
# import tempfile
# import os
# token = os.environ['apikey']
# #discord_id = os.environ['discord-id']
# API_HOST = "https://labs-proxy.voicemod.net/"
# def download_file(url):
# response = requests.get(url)
# if response.status_code == 200:
# with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
# tmp_file.write(response.content)
# tmp_file.flush()
# return tmp_file.name
# else:
# print("Error: Unable to download file")
# def tts(text):
# url = API_HOST + "api/v1/tts/create"
# payload = {
# "text": text[:200] if len(text) > 200 else text,
# "voiceId": "6926ecc5-ff5e-47c6-912b-3ffdb880bf56" # Narrator
# }
# headers = {
# 'x-api-key': token,
# }
# response = requests.request("POST", url, headers=headers, json=payload)
# jsonResp = response.json()
# return gr.make_waveform(download_file(jsonResp['audioUrl']))
# demo = gr.Interface(
# fn=tts,
# inputs="text",
# outputs="audio"
# )
# demo.launch()
# import openai
# import os
# #from pymongo import MongoClient
# api_key = os.environ.get("OPENAI_API_KEY")
# def transcribe_audio(filepath):
# audio = open(filepath, "rb")
# transcript = openai.Audio.transcribe("whisper-1", audio)
# return transcript['text']
# # Create a Gradio Tabbed Interface
# iface = gr.Interface(
# fn=transcribe_audio,
# inputs= gr.Audio(source="upload", type="filepath"),
# outputs="text",
# )
# iface.launch()