Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,31 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
import torch.serialization
|
| 8 |
|
| 9 |
-
torch.serialization.
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from bark import generate_audio, SAMPLE_RATE
|
| 4 |
+
from scipy.io.wavfile import write as write_wav
|
| 5 |
+
import numpy as np
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
# Fix for PyTorch 2.6+ loading bug
|
| 9 |
+
import numpy.core.multiarray
|
| 10 |
import torch.serialization
|
| 11 |
|
| 12 |
+
torch.serialization._use_new_zipfile_serialization = False
|
| 13 |
+
|
| 14 |
+
def synthesize(text_prompt, history_prompt=None):
|
| 15 |
+
audio_array = generate_audio(text_prompt, history_prompt=history_prompt)
|
| 16 |
+
output_path = "output.wav"
|
| 17 |
+
write_wav(output_path, SAMPLE_RATE, audio_array)
|
| 18 |
+
return output_path
|
| 19 |
+
|
| 20 |
+
demo = gr.Interface(
|
| 21 |
+
fn=synthesize,
|
| 22 |
+
inputs=[
|
| 23 |
+
gr.Textbox(label="Enter Text to Speak"),
|
| 24 |
+
gr.Textbox(label="History Prompt Name (optional, e.g. v2/en_speaker_6)")
|
| 25 |
+
],
|
| 26 |
+
outputs=gr.Audio(label="Generated Voice", type="filepath"),
|
| 27 |
+
title="CloneVoicetts - Real Voice Cloning (Bark)",
|
| 28 |
+
description="Upload a demo voice to train as history prompt (optional), then enter any text to generate speech in that style.",
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
demo.launch()
|