jytole commited on
Commit
7023739
·
1 Parent(s): 837762b

Changed to simplified implementation of audioldm

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -1,8 +1,20 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return ("hello" + name)
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  iface.launch()
 
1
  import gradio as gr
2
 
3
+ from diffusers import AudioLDMPipeline
4
+ import torch
5
+ # import scipy
6
 
7
+ repo_id = "cvssp/audioldm-s-full-v2"
8
+ pipe = AudioLDMPipeline.from_pretrained(repo_id, torch_dtype=torch.float32)
9
+ pipe = pipe.to("cpu")
10
+
11
+ def texttoaudio(prompt):
12
+ audio = pipe(prompt, num_inference_steps=10, audio_length_in_s=5.0).audios[0]
13
+
14
+ # save the audio sample as a .wav file
15
+ # scipy.io.wavfile.write("output.wav", rate=16000, data=audio)
16
+ return (rate=16000, data=audio)
17
+
18
+ iface = gr.Interface(fn=texttoaudio, inputs="text", outputs="audio")
19
 
20
  iface.launch()