Update handler.py
Browse files- handler.py +2 -28
handler.py
CHANGED
@@ -4,9 +4,7 @@ import torch
|
|
4 |
import soundfile as sf
|
5 |
from transformers import AutoTokenizer, AutoModelForTextToWaveform
|
6 |
import cloudinary.uploader
|
7 |
-
import
|
8 |
-
from tkinter import ttk
|
9 |
-
import pygame
|
10 |
# Configure logging
|
11 |
logging.basicConfig(level=logging.DEBUG)
|
12 |
# Configure logging
|
@@ -36,7 +34,7 @@ class EndpointHandler():
|
|
36 |
# Save the audio to a file
|
37 |
sf.write("StoryAudio.wav", outputs["waveform"][0].numpy(), self.model.config.sampling_rate)
|
38 |
uploadGraphFile("StoryAudio.wav")
|
39 |
-
|
40 |
#return 'StoryAudio.wav'
|
41 |
# Check if the request was successful
|
42 |
|
@@ -50,27 +48,3 @@ def uploadGraphFile(fileName):
|
|
50 |
# Upload a file to Cloudinary
|
51 |
result = cloudinary.uploader.upload(fileName, folder="poc-graph", resource_type="raw")
|
52 |
return result
|
53 |
-
|
54 |
-
def play_audio():
|
55 |
-
pygame.mixer.music.load("StoryAudio.wav")
|
56 |
-
pygame.mixer.music.play()
|
57 |
-
|
58 |
-
def stop_audio():
|
59 |
-
pygame.mixer.music.stop()
|
60 |
-
|
61 |
-
def playAudioFile():
|
62 |
-
root = tk.Tk()
|
63 |
-
root.title("Audio Player")
|
64 |
-
|
65 |
-
# Create a play button
|
66 |
-
play_button = tk.Button(root, text="Play", command=play_audio)
|
67 |
-
play_button.pack()
|
68 |
-
|
69 |
-
# Create a stop button
|
70 |
-
stop_button = tk.Button(root, text="Stop", command=stop_audio)
|
71 |
-
stop_button.pack()
|
72 |
-
|
73 |
-
# Create a progress bar
|
74 |
-
progress_bar = ttk.Progressbar(root, orient="horizontal", length=200, mode="determinate")
|
75 |
-
progress_bar.pack()
|
76 |
-
root.mainloop()
|
|
|
4 |
import soundfile as sf
|
5 |
from transformers import AutoTokenizer, AutoModelForTextToWaveform
|
6 |
import cloudinary.uploader
|
7 |
+
import streamlit as st
|
|
|
|
|
8 |
# Configure logging
|
9 |
logging.basicConfig(level=logging.DEBUG)
|
10 |
# Configure logging
|
|
|
34 |
# Save the audio to a file
|
35 |
sf.write("StoryAudio.wav", outputs["waveform"][0].numpy(), self.model.config.sampling_rate)
|
36 |
uploadGraphFile("StoryAudio.wav")
|
37 |
+
st.audio("StoryAudio.wav")
|
38 |
#return 'StoryAudio.wav'
|
39 |
# Check if the request was successful
|
40 |
|
|
|
48 |
# Upload a file to Cloudinary
|
49 |
result = cloudinary.uploader.upload(fileName, folder="poc-graph", resource_type="raw")
|
50 |
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|