Spaces:
Running
Running
michellelychan
commited on
Commit
•
467f7e2
1
Parent(s):
f5c319c
Update app.py
Browse files
app.py
CHANGED
@@ -19,9 +19,24 @@ processor = AutoProcessor.from_pretrained("suno/bark")
|
|
19 |
voice_preset = "v2/en_speaker_3"
|
20 |
|
21 |
# generate audio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
def generate_audio(text, preset, output_file_name="bark_generation"):
|
23 |
file_name = output_file_name + ".wav"
|
24 |
inputs = processor(text, voice_preset=preset)
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
audio_array = model.generate(**inputs)
|
26 |
audio_array = audio_array.cpu().numpy().squeeze()
|
27 |
sample_rate = model.generation_config.sample_rate
|
|
|
19 |
voice_preset = "v2/en_speaker_3"
|
20 |
|
21 |
# generate audio
|
22 |
+
# def generate_audio(text, preset, output_file_name="bark_generation"):
|
23 |
+
# file_name = output_file_name + ".wav"
|
24 |
+
# inputs = processor(text, voice_preset=preset)
|
25 |
+
# audio_array = model.generate(**inputs)
|
26 |
+
# audio_array = audio_array.cpu().numpy().squeeze()
|
27 |
+
# sample_rate = model.generation_config.sample_rate
|
28 |
+
# write_wav(file_name, sample_rate, audio_array)
|
29 |
+
# return file_name
|
30 |
+
|
31 |
def generate_audio(text, preset, output_file_name="bark_generation"):
|
32 |
file_name = output_file_name + ".wav"
|
33 |
inputs = processor(text, voice_preset=preset)
|
34 |
+
|
35 |
+
# Ensure the inputs are on the right device
|
36 |
+
for k, v in inputs.items():
|
37 |
+
if isinstance(v, torch.Tensor):
|
38 |
+
inputs[k] = v.to(device)
|
39 |
+
|
40 |
audio_array = model.generate(**inputs)
|
41 |
audio_array = audio_array.cpu().numpy().squeeze()
|
42 |
sample_rate = model.generation_config.sample_rate
|