File size: 1,954 Bytes
32e218a 989f593 32e218a 989f593 32e218a 989f593 e30c131 989f593 e30c131 989f593 e30c131 2176d40 989f593 e30c131 989f593 2176d40 989f593 2176d40 989f593 32e218a 2176d40 989f593 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
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() |