Update handler.py
Browse files- handler.py +12 -3
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
|
@@ -33,8 +33,17 @@ class EndpointHandler():
|
|
33 |
|
34 |
# Save the audio to a file
|
35 |
sf.write("StoryAudio.wav", outputs["waveform"][0].numpy(), self.model.config.sampling_rate)
|
36 |
-
|
37 |
return 'StoryAudio.wav'
|
38 |
# Check if the request was successful
|
39 |
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import torch
|
4 |
import soundfile as sf
|
5 |
from transformers import AutoTokenizer, AutoModelForTextToWaveform
|
6 |
+
import cloudinary.uploader
|
7 |
# Configure logging
|
8 |
logging.basicConfig(level=logging.DEBUG)
|
9 |
# Configure logging
|
|
|
33 |
|
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 |
return 'StoryAudio.wav'
|
38 |
# Check if the request was successful
|
39 |
|
40 |
+
def uploadGraphFile(fileName):
|
41 |
+
# Configure Cloudinary credentials
|
42 |
+
cloudinary.config(
|
43 |
+
cloud_name = "dm9tdqvp6",
|
44 |
+
api_key ="793865869491345",
|
45 |
+
api_secret = "0vhdvBoM35IWcO29NyI04Qj1PMo"
|
46 |
+
)
|
47 |
+
# Upload a file to Cloudinary
|
48 |
+
result = cloudinary.uploader.upload(fileName, folder="poc-graph", resource_type="raw")
|
49 |
+
return result
|