Kvikontent commited on
Commit
7227afb
·
verified ·
1 Parent(s): e90cdbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -23,14 +23,18 @@ def imgquery(payload):
23
  response = requests.post(API_URL_IMG, headers=headers, json=payload)
24
  return response.content
25
 
 
 
26
  def generate_audio(prompt):
27
  audio_bytes = query({"inputs": prompt})
28
-
29
- with open("output_audio.mp3", "wb") as f:
30
  f.write(audio_bytes)
31
-
32
  display(Audio(data=audio_bytes, autoplay=False))
33
- return audio_bytes
 
 
34
 
35
  def generate_image(prompt):
36
  image_bytes = imgquery({
@@ -57,12 +61,12 @@ if generate_btn:
57
  with audio1:
58
  st.image(cover1)
59
  st.header(title1)
60
- st.audio(audio1)
61
  with audio2:
62
  st.image(cover2)
63
  st.header(title2)
64
- st.audio(audio2)
65
  with audio3:
66
  st.image(cover3)
67
  st.header(title3)
68
- st.audio(audio3)
 
23
  response = requests.post(API_URL_IMG, headers=headers, json=payload)
24
  return response.content
25
 
26
+ from IPython.display import Audio
27
+
28
  def generate_audio(prompt):
29
  audio_bytes = query({"inputs": prompt})
30
+
31
+ with open("output_audio.wav", "wb") as f:
32
  f.write(audio_bytes)
33
+
34
  display(Audio(data=audio_bytes, autoplay=False))
35
+
36
+ return "output_audio.wav"
37
+
38
 
39
  def generate_image(prompt):
40
  image_bytes = imgquery({
 
61
  with audio1:
62
  st.image(cover1)
63
  st.header(title1)
64
+ st.audio(audio1, format="audio/wav")
65
  with audio2:
66
  st.image(cover2)
67
  st.header(title2)
68
+ st.audio(audio2, format="audio/wav")
69
  with audio3:
70
  st.image(cover3)
71
  st.header(title3)
72
+ st.audio(audio3, format="audio/wav")