Elesis commited on
Commit
c8f6714
1 Parent(s): 26e1f20

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+
3
+ import streamlit as st
4
+ import numpy as np
5
+ import torch
6
+ from espnet2.bin.tts_inference import Text2Speech
7
+ from scipy.io.wavfile import write
8
+ from PIL import Image
9
+
10
+
11
+ fs, lang = 44100, "Japanese"
12
+ model= "./100epoch.pth"
13
+ x = "これはテストメッセージです"
14
+
15
+ text2speech = Text2Speech.from_pretrained(
16
+ model_file=model,
17
+ device="cpu",
18
+ speed_control_alpha=1.0,
19
+ noise_scale=0.333,
20
+ noise_scale_dur=0.333,
21
+ )
22
+ pause = np.zeros(30000, dtype=np.float32)
23
+
24
+ st.title("おしゃべりAI安倍晋三メーカー")
25
+ image = Image.open('abe.jpg')
26
+ st.image(image)
27
+ text = st.text_area(label='ここにテキストを入力 (Input Text)↓', height=100, max_chars=2048)
28
+
29
+
30
+ if st.button("生成(Generate)"):
31
+ with torch.no_grad():
32
+ wav = text2speech(text)["wav"]
33
+
34
+ wav_list = []
35
+ wav_list.append(np.concatenate([wav.view(-1).cpu().numpy(), pause]))
36
+ final_wav = np.concatenate(wav_list)
37
+ st.audio(final_wav, sample_rate=fs)