Spaces:
Configuration error
Configuration error
no message
Browse files
webui.py
CHANGED
|
@@ -21,6 +21,8 @@ import torch
|
|
| 21 |
import torchaudio
|
| 22 |
import random
|
| 23 |
import librosa
|
|
|
|
|
|
|
| 24 |
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 25 |
sys.path.append('{}/third_party/Matcha-TTS'.format(ROOT_DIR))
|
| 26 |
from cosyvoice.cli.cosyvoice import CosyVoice
|
|
@@ -35,7 +37,7 @@ instruct_dict = {'预训练音色': '1. 选择预训练音色\n2. 点击生成
|
|
| 35 |
stream_mode_list = [('否', False), ('是', True)]
|
| 36 |
max_val = 0.8
|
| 37 |
|
| 38 |
-
|
| 39 |
def generate_seed():
|
| 40 |
seed = random.randint(1, 100000000)
|
| 41 |
return {
|
|
@@ -43,7 +45,7 @@ def generate_seed():
|
|
| 43 |
"value": seed
|
| 44 |
}
|
| 45 |
|
| 46 |
-
|
| 47 |
def postprocess(speech, top_db=60, hop_length=220, win_length=440):
|
| 48 |
speech, _ = librosa.effects.trim(
|
| 49 |
speech, top_db=top_db,
|
|
@@ -55,11 +57,11 @@ def postprocess(speech, top_db=60, hop_length=220, win_length=440):
|
|
| 55 |
speech = torch.concat([speech, torch.zeros(1, int(target_sr * 0.2))], dim=1)
|
| 56 |
return speech
|
| 57 |
|
| 58 |
-
|
| 59 |
def change_instruction(mode_checkbox_group):
|
| 60 |
return instruct_dict[mode_checkbox_group]
|
| 61 |
|
| 62 |
-
|
| 63 |
def generate_audio(tts_text, mode_checkbox_group, sft_dropdown, prompt_text, prompt_wav_upload, prompt_wav_record, instruct_text,
|
| 64 |
seed, stream, speed):
|
| 65 |
if prompt_wav_upload is not None:
|
|
|
|
| 21 |
import torchaudio
|
| 22 |
import random
|
| 23 |
import librosa
|
| 24 |
+
import spaces
|
| 25 |
+
|
| 26 |
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 27 |
sys.path.append('{}/third_party/Matcha-TTS'.format(ROOT_DIR))
|
| 28 |
from cosyvoice.cli.cosyvoice import CosyVoice
|
|
|
|
| 37 |
stream_mode_list = [('否', False), ('是', True)]
|
| 38 |
max_val = 0.8
|
| 39 |
|
| 40 |
+
@spaces.GPU
|
| 41 |
def generate_seed():
|
| 42 |
seed = random.randint(1, 100000000)
|
| 43 |
return {
|
|
|
|
| 45 |
"value": seed
|
| 46 |
}
|
| 47 |
|
| 48 |
+
@spaces.GPU
|
| 49 |
def postprocess(speech, top_db=60, hop_length=220, win_length=440):
|
| 50 |
speech, _ = librosa.effects.trim(
|
| 51 |
speech, top_db=top_db,
|
|
|
|
| 57 |
speech = torch.concat([speech, torch.zeros(1, int(target_sr * 0.2))], dim=1)
|
| 58 |
return speech
|
| 59 |
|
| 60 |
+
@spaces.GPU
|
| 61 |
def change_instruction(mode_checkbox_group):
|
| 62 |
return instruct_dict[mode_checkbox_group]
|
| 63 |
|
| 64 |
+
@spaces.GPU
|
| 65 |
def generate_audio(tts_text, mode_checkbox_group, sft_dropdown, prompt_text, prompt_wav_upload, prompt_wav_record, instruct_text,
|
| 66 |
seed, stream, speed):
|
| 67 |
if prompt_wav_upload is not None:
|