Update handler.py
Browse files- handler.py +3 -2
handler.py
CHANGED
|
@@ -3,7 +3,7 @@ import logging
|
|
| 3 |
import torch
|
| 4 |
import soundfile as sf
|
| 5 |
from transformers import AutoTokenizer, AutoModelForTextToWaveform
|
| 6 |
-
|
| 7 |
# Configure logging
|
| 8 |
logging.basicConfig(level=logging.DEBUG)
|
| 9 |
# Configure logging
|
|
@@ -13,6 +13,7 @@ logging.basicConfig(level=logging.WARNING)
|
|
| 13 |
|
| 14 |
|
| 15 |
|
|
|
|
| 16 |
class EndpointHandler():
|
| 17 |
def __init__(self, path=""):
|
| 18 |
|
|
@@ -32,7 +33,7 @@ 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 |
|
|
|
|
| 3 |
import torch
|
| 4 |
import soundfile as sf
|
| 5 |
from transformers import AutoTokenizer, AutoModelForTextToWaveform
|
| 6 |
+
import streamlit as st
|
| 7 |
# Configure logging
|
| 8 |
logging.basicConfig(level=logging.DEBUG)
|
| 9 |
# Configure logging
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
+
|
| 17 |
class EndpointHandler():
|
| 18 |
def __init__(self, path=""):
|
| 19 |
|
|
|
|
| 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 |
return 'StoryAudio.wav'
|
| 38 |
# Check if the request was successful
|
| 39 |
|