forked from shirowanisan/tsukuyomichan-talksoft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
69 lines (48 loc) · 1.67 KB
/
main.py
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
import os
import tkinter as tk
import numpy as np
import simpleaudio as sa
import soundfile as sf
from tsukuyomichan_talksoft import TsukuyomichanTalksoft
# config
MAX_WAV_VALUE = 32768.0
fs = 24000
wav = []
seed = 0
text = ''
voice = ''
talksoft = TsukuyomichanTalksoft(model_version='v.1.1.0')
# GUI
root = tk.Tk()
root.geometry("550x500")
root.title('シロワニさんのつくよみちゃんトークソフト')
textbox_label = tk.Label(text='テキスト')
textbox_label.grid(row=0, column=0, padx=30, pady=15)
textbox = tk.Entry(width=50)
textbox.grid(row=1, column=0, padx=30, pady=15)
seed_label = tk.Label(text='seed')
seed_label.grid(row=2, column=0, padx=30, pady=15)
seed_box = tk.Entry(width=5)
seed_box.grid(row=3, column=0, padx=10, pady=15)
load_label = tk.Label(text='何も作ってません')
load_label.grid(row=4, column=0, padx=30, pady=15)
def make_tsukuyomichan_voice():
global text, seed, wav
text = textbox.get()
seed = int(seed_box.get())
wav = talksoft.generate_voice(text, seed)
wav = wav * MAX_WAV_VALUE
wav = wav.astype(np.int16)
load_label['text'] = f"「{text}」「{seed}」で作りました"
def play_voice():
sa.play_buffer(wav, 1, 2, fs)
def save_voice():
os.makedirs('output', exist_ok=True)
sf.write(f"output/{text}_{seed}.wav", wav, fs, 'PCM_16')
run_button = tk.Button(text='作る', command=make_tsukuyomichan_voice)
run_button.grid(row=5, column=0, padx=30, pady=15)
run_button = tk.Button(text='聞く', command=play_voice)
run_button.grid(row=6, column=0, padx=10, pady=15)
run_button = tk.Button(text='保存', command=save_voice)
run_button.grid(row=7, column=0, padx=10, pady=15)
root.mainloop()