Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import soundfile as sf
|
|
| 4 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 5 |
from xcodec2.modeling_xcodec2 import XCodec2Model
|
| 6 |
import tempfile
|
| 7 |
-
|
| 8 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 9 |
|
| 10 |
####################
|
|
@@ -39,7 +39,7 @@ def extract_speech_ids(speech_tokens_str):
|
|
| 39 |
else:
|
| 40 |
print(f"Unexpected token: {token_str}")
|
| 41 |
return speech_ids
|
| 42 |
-
|
| 43 |
def text2speech(input_text, speaker_choice):
|
| 44 |
"""
|
| 45 |
将文本转为语音波形,并返回音频文件路径
|
|
@@ -105,8 +105,8 @@ demo = gr.Interface(
|
|
| 105 |
inputs=[gr.Textbox(label="Enter text", lines=5),
|
| 106 |
gr.Dropdown(choices=speaker_choices, label="Select Speaker", value="puck")],
|
| 107 |
outputs=gr.Audio(label="Generated Audio", type="filepath"),
|
| 108 |
-
title="Llasa-1B TTS
|
| 109 |
-
description="Input a piece of text in English
|
| 110 |
)
|
| 111 |
|
| 112 |
if __name__ == "__main__":
|
|
|
|
| 4 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 5 |
from xcodec2.modeling_xcodec2 import XCodec2Model
|
| 6 |
import tempfile
|
| 7 |
+
import spaces
|
| 8 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 9 |
|
| 10 |
####################
|
|
|
|
| 39 |
else:
|
| 40 |
print(f"Unexpected token: {token_str}")
|
| 41 |
return speech_ids
|
| 42 |
+
@spaces.GPU
|
| 43 |
def text2speech(input_text, speaker_choice):
|
| 44 |
"""
|
| 45 |
将文本转为语音波形,并返回音频文件路径
|
|
|
|
| 105 |
inputs=[gr.Textbox(label="Enter text", lines=5),
|
| 106 |
gr.Dropdown(choices=speaker_choices, label="Select Speaker", value="puck")],
|
| 107 |
outputs=gr.Audio(label="Generated Audio", type="filepath"),
|
| 108 |
+
title="Llasa-1B TTS finetuned using shb777/gemini-flash-2.0-speech",
|
| 109 |
+
description="Input a piece of text in English, select a speaker (puck or kore), and click to generate speech.\nModel: HKUSTAudio/Llasa-1B-two-speakers-kore-puck + HKUSTAudio/xcodec2"
|
| 110 |
)
|
| 111 |
|
| 112 |
if __name__ == "__main__":
|