kumararvindibs commited on
Commit
4a7a644
·
verified ·
1 Parent(s): 669b0a4

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +17 -3
handler.py CHANGED
@@ -11,7 +11,8 @@ logging.basicConfig(level=logging.ERROR)
11
  # Configure logging
12
  logging.basicConfig(level=logging.WARNING)
13
 
14
-
 
15
 
16
  class EndpointHandler():
17
  def __init__(self, path=""):
@@ -32,8 +33,21 @@ class EndpointHandler():
32
 
33
  # Save the audio to a file
34
  sf.write("StoryAudio.wav", outputs["waveform"][0].numpy(), self.model.config.sampling_rate)
35
-
36
- return 'StoryAudio.wav'
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  # Check if the request was successful
38
 
39
 
 
11
  # Configure logging
12
  logging.basicConfig(level=logging.WARNING)
13
 
14
+ import streamlit as st
15
+ import pygame
16
 
17
  class EndpointHandler():
18
  def __init__(self, path=""):
 
33
 
34
  # Save the audio to a file
35
  sf.write("StoryAudio.wav", outputs["waveform"][0].numpy(), self.model.config.sampling_rate)
36
+ st.audio("StoryAudio.wav")
37
+ # pygame.mixer.init()
38
+ # pygame.mixer.music.load("StoryAudio.wav")
39
+ # pygame.mixer.music.play()
40
+ #return 'StoryAudio.wav'
41
+ #return {"audio_file_path": 'StoryAudio.wav'}
42
+ # with open("StoryAudio.wav", "rb") as f:
43
+ # audio_content = f.read()
44
+
45
+ # # Set the response content type
46
+ # response_headers = {"Content-Type": "audio/wav"}
47
+
48
+ # Return the binary content of the audio file along with the response headers
49
+ #return send_file("StoryAudio.wav", mimetype="audio/wav", as_attachment=True)
50
+
51
  # Check if the request was successful
52
 
53