Spaces:
Runtime error
Runtime error
import gradio as gr | |
import json | |
#from bark import SAMPLE_RATE, generate_audio, preload_models | |
#from bark.generation import SUPPORTED_LANGS | |
#from share_btn imposrt community_icon_html, loading_icon_html, share_js | |
#from flask import Flask, jsonify | |
DEBUG_MODE = False | |
TITLE = "《★~ N.N.F. Text To Speech V2 ~★ 》" | |
#FAVICON = "https://aeiljuispo.cloudimg.io/v7/https://cdn-uploads.huggingface.co/production/uploads/65b453089151075ad87382ea/9NpWGb4xBrZovX1o7DF-5.jpeg" | |
INPUT_TEXT_PROMPT_EXAMPLE=""" | |
Não sou nada, | |
não serei nada, | |
não posso querer ser nada. | |
À parte isso, tenho em mim todos os sonhos do mundo. | |
""" | |
DECRIPTION = """ | |
This is a simple Text To Speech (TTS) model that uses the XTTS model from Hugging Face. | |
You can use this model to generate audio from text in multiple languages. | |
It can be used as an API or as a standalone application. | |
""" | |
def predict(text, lang, audio, request: gr.Request): | |
output_text = {"verdict ": "SUCCESS"} # Initialize as a dictionary | |
output_text["Text"] = text | |
output_text["Language"] = lang | |
if request: | |
# Convert headers to a dictionary and include them in the output_text | |
output_text["headers"] = dict(request.headers.items()) | |
output_text_json = json.dumps(output_text) | |
return output_text_json | |
io = gr.Interface( | |
fn=predict, | |
inputs=[ | |
#definition of the input text to parse | |
gr.Textbox( | |
label="Text Prompt", | |
info="One or two sentences at a time is better", | |
value=INPUT_TEXT_PROMPT_EXAMPLE, | |
), | |
gr.Dropdown( | |
label="Language", | |
info="Select an output language for the reader", | |
choices=[ | |
"en", | |
"es", | |
"fr", | |
"it", | |
"pt", | |
"nl", | |
], | |
#max_choices=1, | |
value="pt", | |
), | |
gr.Audio( | |
#label="Reference Audio", | |
#info="Click on the ✎ button to upload your own target speaker audio", | |
#type="filepath", | |
#value="examples/female.wav", | |
), | |
], | |
outputs=[ | |
#gr.Video(label="Waveform Visual"), | |
"json", | |
], | |
title=TITLE, | |
description=DECRIPTION, | |
#favicon_path=FAVICON, | |
#article=article, | |
#cache_examples=False, | |
#examples=examples, | |
).queue().launch(share=True) | |