Spaces:
Paused
Paused
zxsipola123456
commited on
Commit
•
199627b
1
Parent(s):
0fca0e2
Update app.py
Browse files
app.py
CHANGED
@@ -28,18 +28,6 @@ async def text_to_speech_edge(text, language_code):
|
|
28 |
|
29 |
return "语音合成完成:{}".format(text), tmp_path
|
30 |
|
31 |
-
# 声音更改函数
|
32 |
-
#def voice_change(audio_in, audio_ref):
|
33 |
-
#samplerate1, data1 = wavfile.read(audio_in)
|
34 |
-
#samplerate2, data2 = wavfile.read(audio_ref)
|
35 |
-
#write("./audio_in.wav", samplerate1, data1)
|
36 |
-
#write("./audio_ref.wav", samplerate2, data2)
|
37 |
-
|
38 |
-
#query_seq = knn_vc.get_features("./audio_in.wav")
|
39 |
-
#matching_set = knn_vc.get_matching_set(["./audio_ref.wav"])
|
40 |
-
#out_wav = knn_vc.match(query_seq, matching_set, topk=4)
|
41 |
-
#torchaudio.save('output.wav', out_wav[None], 16000)
|
42 |
-
#return 'output.wav'
|
43 |
def voice_change(audio_in, audio_ref):
|
44 |
samplerate1, data1 = wavfile.read(audio_in)
|
45 |
samplerate2, data2 = wavfile.read(audio_ref)
|
@@ -58,31 +46,7 @@ def voice_change(audio_in, audio_ref):
|
|
58 |
torchaudio.save(output_path, out_wav[None], 16000)
|
59 |
return output_path
|
60 |
|
61 |
-
|
62 |
-
# samplerate1, data1 = wavfile.read(audio_in)
|
63 |
-
# samplerate2, data2 = wavfile.read(audio_ref)
|
64 |
-
|
65 |
-
# # 强制匹配音频文件的长度
|
66 |
-
# max_length = max(data1.shape[0], data2.shape[0])
|
67 |
-
|
68 |
-
# if data1.shape[0] < max_length:
|
69 |
-
# data1 = np.pad(data1, (0, max_length - data1.shape[0]), mode='constant')
|
70 |
-
# if data2.shape[0] < max_length:
|
71 |
-
# data2 = np.pad(data2, (0, max_length - data2.shape[0]), mode='constant')
|
72 |
-
|
73 |
-
# with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_audio_in, \
|
74 |
-
# tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_audio_ref:
|
75 |
-
# audio_in_path = tmp_audio_in.name
|
76 |
-
# audio_ref_path = tmp_audio_ref.name
|
77 |
-
# wavfile.write(audio_in_path, samplerate1, data1)
|
78 |
-
# wavfile.write(audio_ref_path, samplerate2, data2)
|
79 |
-
|
80 |
-
# query_seq = knn_vc.get_features(audio_in_path)
|
81 |
-
# matching_set = knn_vc.get_matching_set([audio_ref_path])
|
82 |
-
# out_wav = knn_vc.match(query_seq, matching_set, topk=4)
|
83 |
-
# output_path = 'output.wav'
|
84 |
-
# torchaudio.save(output_path, torch.tensor(out_wav)[None], 16000)
|
85 |
-
# return output_path
|
86 |
# 文字转语音(OpenAI)
|
87 |
def tts(text, model, voice, api_key):
|
88 |
if len(text) > 300:
|
@@ -110,10 +74,10 @@ app = gr.Blocks()
|
|
110 |
|
111 |
with app:
|
112 |
gr.Markdown("# <center>OpenAI TTS + 3秒实时AI变声+需要使用中转key</center>")
|
113 |
-
gr.Markdown("### <center>中转key购买地址https://buy.sipola.cn</center>")
|
114 |
with gr.Tab("TTS"):
|
115 |
with gr.Row(variant='panel'):
|
116 |
-
api_key = gr.Textbox(type='password', label='API Key', placeholder='
|
117 |
model = gr.Dropdown(choices=['tts-1','tts-1-hd'], label='请选择模型(tts-1推理更快,tts-1-hd音质更好)', value='tts-1')
|
118 |
voice = gr.Dropdown(choices=['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'], label='请选择一个说话人', value='alloy')
|
119 |
with gr.Row():
|
|
|
28 |
|
29 |
return "语音合成完成:{}".format(text), tmp_path
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
def voice_change(audio_in, audio_ref):
|
32 |
samplerate1, data1 = wavfile.read(audio_in)
|
33 |
samplerate2, data2 = wavfile.read(audio_ref)
|
|
|
46 |
torchaudio.save(output_path, out_wav[None], 16000)
|
47 |
return output_path
|
48 |
|
49 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
# 文字转语音(OpenAI)
|
51 |
def tts(text, model, voice, api_key):
|
52 |
if len(text) > 300:
|
|
|
74 |
|
75 |
with app:
|
76 |
gr.Markdown("# <center>OpenAI TTS + 3秒实时AI变声+需要使用中转key</center>")
|
77 |
+
gr.Markdown("### <center>中转key购买地址[here](https://buy.sipola.cn),ai文案生成可使用中转key,请访问 [here](https://ai.sipola.cn)</center>")
|
78 |
with gr.Tab("TTS"):
|
79 |
with gr.Row(variant='panel'):
|
80 |
+
api_key = gr.Textbox(type='password', label='API Key', placeholder='请在此填写您的中转API Key')
|
81 |
model = gr.Dropdown(choices=['tts-1','tts-1-hd'], label='请选择模型(tts-1推理更快,tts-1-hd音质更好)', value='tts-1')
|
82 |
voice = gr.Dropdown(choices=['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'], label='请选择一个说话人', value='alloy')
|
83 |
with gr.Row():
|