Hjgugugjhuhjggg commited on
Commit
67f13e5
·
verified ·
1 Parent(s): 6a47f34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -143,6 +143,14 @@ async def generate(request: Request, body: GenerateRequest):
143
  audio_bytes = audio_bytesio.getvalue()
144
  return Response(content=audio_bytes, media_type="audio/wav")
145
 
 
 
 
 
 
 
 
 
146
  elif body.task_type == "text-to-video":
147
  try:
148
  generator = pipeline("text-to-video", model=model, tokenizer=tokenizer, device=device)
 
143
  audio_bytes = audio_bytesio.getvalue()
144
  return Response(content=audio_bytes, media_type="audio/wav")
145
 
146
+ elif body.task_type == "text-to-audio":
147
+ generator = pipeline("text-to-audio", model=model, tokenizer=tokenizer, device=device)
148
+ audio = generator(body.input_text)
149
+ audio_bytesio = BytesIO()
150
+ sf.write(audio_bytesio, audio["sampling_rate"], np.int16(audio["audio"]))
151
+ audio_bytes = audio_bytesio.getvalue()
152
+ return Response(content=audio_bytes, media_type="audio/wav")
153
+
154
  elif body.task_type == "text-to-video":
155
  try:
156
  generator = pipeline("text-to-video", model=model, tokenizer=tokenizer, device=device)