Spaces:
Runtime error
Runtime error
File size: 943 Bytes
c8f6714 3e11472 c8f6714 3e11472 c8f6714 |
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 |
import time
import streamlit as st
import numpy as np
import torch
from espnet2.bin.tts_inference import Text2Speech
from scipy.io.wavfile import write
from PIL import Image
fs, lang = 44100, "Japanese"
model= "./100epoch.pth"
x = "JRζ±ζ₯ζ¬γγε©η¨γγ γγγΎγγ¦γγγγγ¨γγγγγΎγγ"
text2speech = Text2Speech.from_pretrained(
model_file=model,
device="cpu",
speed_control_alpha=1.0,
noise_scale=0.333,
noise_scale_dur=0.333,
)
pause = np.zeros(30000, dtype=np.float32)
st.title("JREast_Auto_anounce_TTS")
text = st.text_area(label='γγγ«γγγΉγγε
₯ε (Input Text)β', height=100, max_chars=2048)
if st.button("ηζοΌGenerateοΌ"):
with torch.no_grad():
wav = text2speech(text)["wav"]
wav_list = []
wav_list.append(np.concatenate([wav.view(-1).cpu().numpy(), pause]))
final_wav = np.concatenate(wav_list)
st.audio(final_wav, sample_rate=fs)
|