Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
import librosa | |
import numpy as np | |
from scipy.io.wavfile import write | |
def narrate_text(text): | |
narrator = pipeline("text-to-speech", model="kakao-enterprise/vits-ljs") | |
narrated_text = narrator(text) | |
audio_data = narrated_text["audio"][0] | |
sampling_rate = narrated_text["sampling_rate"] | |
audio_data = librosa.resample(audio_data, orig_sr=sampling_rate, target_sr=22050) | |
audio_data = (audio_data * 32767).astype(np.int16) | |
with open("output.wav", "wb") as f: | |
write(f, 22050, audio_data) | |
return "output.wav" | |
gr.Interface( | |
fn=narrate_text, | |
inputs=gr.Textbox(label="Enter Text Here", | |
lines=7), | |
outputs="audio", | |
title="Speak Out Loud - Text to Speech Assistant", | |
description="Upload the text that you want to hear out loud!!!", | |
article = | |
'''<div> | |
<p style="text-align: center"> All you need to do is to upload your text and hit submit, then wait for compiling. After that click on Play/Pause for listing to the audio. The audio is saved in a wav format.</p> | |
</div>''', | |
).launch() |