MariaKaiser commited on
Commit
43378d2
·
verified ·
1 Parent(s): cda4205

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -120,6 +120,21 @@ def root():
120
  return {"message": "Welcome! Visit /docs for Swagger UI."}
121
 
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  @app.post("/tts/")
124
  async def process_story(story: StoryCreationDTO):
125
  print(story.storyId)
@@ -132,7 +147,13 @@ async def process_story(story: StoryCreationDTO):
132
  for sentence in scene.sentences:
133
  print(sentence.speaker, sentence.sentence)
134
 
135
- return {"status": "Story received"}
 
 
 
 
 
 
136
 
137
 
138
 
 
120
  return {"message": "Welcome! Visit /docs for Swagger UI."}
121
 
122
 
123
+ ########## creating a dummy audio file
124
+ import torchaudio
125
+ import torch
126
+ import os
127
+
128
+ OUTPUT_DIR = "outputs"
129
+ os.makedirs(OUTPUT_DIR, exist_ok=True)
130
+
131
+ dummy_path = os.path.join(OUTPUT_DIR, "dummy.wav")
132
+
133
+ # Generate 1 second of silence at 24kHz
134
+ if not os.path.exists(dummy_path):
135
+ silent = torch.zeros(1, 24000) # 1 channel, 24000 samples
136
+ torchaudio.save(dummy_path, silent, 24000)
137
+
138
  @app.post("/tts/")
139
  async def process_story(story: StoryCreationDTO):
140
  print(story.storyId)
 
147
  for sentence in scene.sentences:
148
  print(sentence.speaker, sentence.sentence)
149
 
150
+ # return dummy audio
151
+ return FileResponse(
152
+ dummy_path,
153
+ media_type="audio/wav",
154
+ filename="output.wav"
155
+ )
156
+ #return {"status": "Story received"}
157
 
158
 
159