Update app.py
Browse files
app.py
CHANGED
@@ -22,6 +22,8 @@ model.load_checkpoint(config, checkpoint_dir="checkpoints/bark", eval=True)
|
|
22 |
|
23 |
def infer(prompt, input_wav_file):
|
24 |
|
|
|
|
|
25 |
# Path to your WAV file
|
26 |
source_path = input_wav_file
|
27 |
|
@@ -42,6 +44,7 @@ def infer(prompt, input_wav_file):
|
|
42 |
|
43 |
text = prompt
|
44 |
|
|
|
45 |
# with random speaker
|
46 |
#output_dict = model.synthesize(text, config, speaker_id="random", voice_dirs=None)
|
47 |
|
@@ -57,7 +60,7 @@ def infer(prompt, input_wav_file):
|
|
57 |
print(output_dict)
|
58 |
|
59 |
sample_rate = 24000 # Replace with the actual sample rate
|
60 |
-
|
61 |
wavfile.write(
|
62 |
'output.wav',
|
63 |
sample_rate,
|
@@ -74,6 +77,7 @@ def infer(prompt, input_wav_file):
|
|
74 |
return "output.wav", f"bark_voices/{file_name}/{contents[1]}", gr.update(visible=False), gr.update(visible=True)
|
75 |
|
76 |
def infer_with_npz(prompt, input_wav_file):
|
|
|
77 |
# Path to your WAV file
|
78 |
source_path = input_wav_file
|
79 |
# Extract the file name without the extension
|
@@ -83,8 +87,12 @@ def infer_with_npz(prompt, input_wav_file):
|
|
83 |
# Print the contents
|
84 |
for item in contents:
|
85 |
print(item)
|
86 |
-
os.remove(contents[0])
|
87 |
|
|
|
|
|
|
|
|
|
|
|
88 |
# cloning a speaker.
|
89 |
text = prompt
|
90 |
# It assumes that you have a speaker file in `bark_voices/speaker_n/speaker.npz`
|
@@ -97,8 +105,10 @@ def infer_with_npz(prompt, input_wav_file):
|
|
97 |
|
98 |
print(output_dict)
|
99 |
|
100 |
-
|
101 |
|
|
|
|
|
102 |
wavfile.write(
|
103 |
'output.wav',
|
104 |
sample_rate,
|
|
|
22 |
|
23 |
def infer(prompt, input_wav_file):
|
24 |
|
25 |
+
print("SAVING THE AUDIO FILE TO WHERE IT BELONGS")
|
26 |
+
|
27 |
# Path to your WAV file
|
28 |
source_path = input_wav_file
|
29 |
|
|
|
44 |
|
45 |
text = prompt
|
46 |
|
47 |
+
print("SYNTHETIZING...")
|
48 |
# with random speaker
|
49 |
#output_dict = model.synthesize(text, config, speaker_id="random", voice_dirs=None)
|
50 |
|
|
|
60 |
print(output_dict)
|
61 |
|
62 |
sample_rate = 24000 # Replace with the actual sample rate
|
63 |
+
print("WRITING WAVE FILE")
|
64 |
wavfile.write(
|
65 |
'output.wav',
|
66 |
sample_rate,
|
|
|
77 |
return "output.wav", f"bark_voices/{file_name}/{contents[1]}", gr.update(visible=False), gr.update(visible=True)
|
78 |
|
79 |
def infer_with_npz(prompt, input_wav_file):
|
80 |
+
print("NEW GENERATION WITH EXISTING .NPZ")
|
81 |
# Path to your WAV file
|
82 |
source_path = input_wav_file
|
83 |
# Extract the file name without the extension
|
|
|
87 |
# Print the contents
|
88 |
for item in contents:
|
89 |
print(item)
|
|
|
90 |
|
91 |
+
first_item = contents[0] # Index 0 corresponds to the first item
|
92 |
+
item_path = os.path.join(f"bark_voices/{file_name}", first_item)
|
93 |
+
os.remove(item_path)
|
94 |
+
|
95 |
+
print("BEGINNING GENERATION")
|
96 |
# cloning a speaker.
|
97 |
text = prompt
|
98 |
# It assumes that you have a speaker file in `bark_voices/speaker_n/speaker.npz`
|
|
|
105 |
|
106 |
print(output_dict)
|
107 |
|
108 |
+
print("WRITING WAVE FILE")
|
109 |
|
110 |
+
sample_rate = 24000 # Replace with the actual sample rate
|
111 |
+
|
112 |
wavfile.write(
|
113 |
'output.wav',
|
114 |
sample_rate,
|