bilal01 commited on
Commit
d96e497
·
1 Parent(s): c3baab1

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +16 -13
main.py CHANGED
@@ -1,14 +1,17 @@
1
- from bark import SAMPLE_RATE, generate_audio, preload_models
2
- from scipy.io.wavfile import write as write_wav
3
- # download and load all models
4
- preload_models()
5
-
6
- # generate audio from text
7
- text_prompt = """
8
- Hello, my name is Suno. And, uh — and I like pizza. [laughs]
9
- But I also have other interests such as playing tic tac toe.
10
- """
11
- speech_array = generate_audio(text_prompt)
12
-
13
- write_wav("/path/to/audio.wav", SAMPLE_RATE, audio_array)
 
 
 
14
 
 
1
+ from transformers import AutoProcessor, AutoModel
2
+ import scipy
3
+
4
+ processor = AutoProcessor.from_pretrained("suno/bark-small")
5
+ model = AutoModel.from_pretrained("suno/bark-small")
6
+
7
+ inputs = processor(
8
+ text=["Hello, my name is Suno. And, uh — and I like pizza. [laughs] But I also have other interests such as playing tic tac toe."],
9
+ return_tensors="pt",
10
+ )
11
+
12
+ speech_values = model.generate(**inputs, do_sample=True)
13
+
14
+
15
+ sampling_rate = model.config.sample_rate
16
+ scipy.io.wavfile.write("bark_out.wav", rate=sampling_rate, data=speech_values.cpu().numpy().squeeze())
17