Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,6 @@ from huggingface_hub import snapshot_download
|
|
6 |
import numpy as np
|
7 |
from scipy.io import wavfile
|
8 |
|
9 |
-
|
10 |
model_ids = [
|
11 |
'suno/bark',
|
12 |
]
|
@@ -49,12 +48,22 @@ def infer(prompt, input_wav_file):
|
|
49 |
|
50 |
# cloning a speaker.
|
51 |
# It assumes that you have a speaker file in `bark_voices/speaker_n/speaker.wav` or `bark_voices/speaker_n/speaker.npz`
|
52 |
-
output_dict = model.synthesize(
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
print(output_dict)
|
54 |
|
55 |
sample_rate = 24000 # Replace with the actual sample rate
|
56 |
|
57 |
-
wavfile.write(
|
|
|
|
|
|
|
|
|
58 |
|
59 |
# List all the files and subdirectories in the given directory
|
60 |
contents = os.listdir(f"bark_voices/{file_name}")
|
@@ -63,13 +72,27 @@ def infer(prompt, input_wav_file):
|
|
63 |
for item in contents:
|
64 |
print(item)
|
65 |
|
66 |
-
return "output.wav"
|
67 |
-
|
68 |
-
gr.Interface(
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
import numpy as np
|
7 |
from scipy.io import wavfile
|
8 |
|
|
|
9 |
model_ids = [
|
10 |
'suno/bark',
|
11 |
]
|
|
|
48 |
|
49 |
# cloning a speaker.
|
50 |
# It assumes that you have a speaker file in `bark_voices/speaker_n/speaker.wav` or `bark_voices/speaker_n/speaker.npz`
|
51 |
+
output_dict = model.synthesize(
|
52 |
+
text,
|
53 |
+
config,
|
54 |
+
speaker_id=f"{file_name}",
|
55 |
+
voice_dirs="bark_voices/"
|
56 |
+
)
|
57 |
+
|
58 |
print(output_dict)
|
59 |
|
60 |
sample_rate = 24000 # Replace with the actual sample rate
|
61 |
|
62 |
+
wavfile.write(
|
63 |
+
'output.wav',
|
64 |
+
sample_rate,
|
65 |
+
output_dict['wav']
|
66 |
+
)
|
67 |
|
68 |
# List all the files and subdirectories in the given directory
|
69 |
contents = os.listdir(f"bark_voices/{file_name}")
|
|
|
72 |
for item in contents:
|
73 |
print(item)
|
74 |
|
75 |
+
return "output.wav", f"bark_voices/{file_name}/{content[1]}"
|
76 |
+
|
77 |
+
gr.Interface(
|
78 |
+
fn=infer,
|
79 |
+
inputs=[
|
80 |
+
gr.Textbox(
|
81 |
+
label="Text to speech prompt"
|
82 |
+
),
|
83 |
+
gr.Audio(
|
84 |
+
label="WAV voice to clone",
|
85 |
+
type="filepath",
|
86 |
+
source="upload"
|
87 |
+
)
|
88 |
+
],
|
89 |
+
outputs=[
|
90 |
+
gr.Audio(
|
91 |
+
label="Text to speech output"
|
92 |
+
),
|
93 |
+
gr.File(
|
94 |
+
label=".npz file"
|
95 |
+
)
|
96 |
+
],
|
97 |
+
title="Instant Voice Cloning"
|
98 |
+
).launch()
|