Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,18 +7,18 @@ import numpy as np
|
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
SAMPLES_PATH = os.path.join(os.getcwd(), "neutts-air", "samples")
|
| 10 |
-
DEFAULT_REF_TEXT = "So I'm live on radio. And I say, well, my dear friend James here clearly, and the whole room just froze. Turns out I'd completely misspoken and mentioned our other friend."
|
| 11 |
DEFAULT_REF_PATH = os.path.join(SAMPLES_PATH, "dave.wav")
|
| 12 |
DEFAULT_GEN_TEXT = "My name is Dave, and um, I'm from London."
|
| 13 |
|
|
|
|
| 14 |
tts = NeuTTSAir(
|
| 15 |
backbone_repo="neuphonic/neutts-air",
|
| 16 |
-
backbone_device="
|
| 17 |
codec_repo="neuphonic/neucodec",
|
| 18 |
-
codec_device="
|
| 19 |
)
|
| 20 |
|
| 21 |
-
@spaces.GPU()
|
| 22 |
def infer(
|
| 23 |
ref_text: str,
|
| 24 |
ref_audio_path: str,
|
|
@@ -35,7 +35,7 @@ def infer(
|
|
| 35 |
tuple [int, np.ndarray]: A tuple containing the sample rate (24000) and the generated audio waveform as a numpy array.
|
| 36 |
"""
|
| 37 |
|
| 38 |
-
gr.Info("Starting inference request!")
|
| 39 |
gr.Info("Encoding reference...")
|
| 40 |
ref_codes = tts.encode_reference(ref_audio_path)
|
| 41 |
|
|
@@ -52,9 +52,9 @@ demo = gr.Interface(
|
|
| 52 |
gr.Textbox(label="Text to Generate", value=DEFAULT_GEN_TEXT),
|
| 53 |
],
|
| 54 |
outputs=gr.Audio(type="numpy", label="Generated Speech"),
|
| 55 |
-
title="NeuTTS-Air☁️",
|
| 56 |
-
description="Upload a reference audio sample, provide the reference text, and enter new text to synthesize."
|
| 57 |
)
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
| 60 |
-
demo.launch(allowed_paths=[SAMPLES_PATH], mcp_server=True, inbrowser=True)
|
|
|
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
SAMPLES_PATH = os.path.join(os.getcwd(), "neutts-air", "samples")
|
| 10 |
+
DEFAULT_REF_TEXT = "So I'm live on radio. And I say, well, my dear friend James here clearly, and the whole room just froze. Turns out I'd completely misspoken and mentioned our other friend."
|
| 11 |
DEFAULT_REF_PATH = os.path.join(SAMPLES_PATH, "dave.wav")
|
| 12 |
DEFAULT_GEN_TEXT = "My name is Dave, and um, I'm from London."
|
| 13 |
|
| 14 |
+
# --- Force CPU usage ---
|
| 15 |
tts = NeuTTSAir(
|
| 16 |
backbone_repo="neuphonic/neutts-air",
|
| 17 |
+
backbone_device="cpu",
|
| 18 |
codec_repo="neuphonic/neucodec",
|
| 19 |
+
codec_device="cpu"
|
| 20 |
)
|
| 21 |
|
|
|
|
| 22 |
def infer(
|
| 23 |
ref_text: str,
|
| 24 |
ref_audio_path: str,
|
|
|
|
| 35 |
tuple [int, np.ndarray]: A tuple containing the sample rate (24000) and the generated audio waveform as a numpy array.
|
| 36 |
"""
|
| 37 |
|
| 38 |
+
gr.Info("Starting inference request (CPU mode)!")
|
| 39 |
gr.Info("Encoding reference...")
|
| 40 |
ref_codes = tts.encode_reference(ref_audio_path)
|
| 41 |
|
|
|
|
| 52 |
gr.Textbox(label="Text to Generate", value=DEFAULT_GEN_TEXT),
|
| 53 |
],
|
| 54 |
outputs=gr.Audio(type="numpy", label="Generated Speech"),
|
| 55 |
+
title="NeuTTS-Air☁️ (CPU Mode)",
|
| 56 |
+
description="Upload a reference audio sample, provide the reference text, and enter new text to synthesize (running on CPU)."
|
| 57 |
)
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
| 60 |
+
demo.launch(allowed_paths=[SAMPLES_PATH], mcp_server=True, inbrowser=True)
|