Update TextGen/router.py
Browse files25 unmodified lines26272829303132134 unmodified lines16716816917017117217317417517617717817918018118218318418525 unmodified lines)class PlayLastMusic(BaseModel):'''plays the lastest created music '''Desicion: str = Field(134 unmodified linesexcept Exception as e:raise HTTPException(status_code=500, detail=str(e))def audio_stream(message):# Generate the audio stream from ElevenLabsfor chunk in Eleven_client.generate(text=message.input, stream=True):yield chunk@app.post("/generate_voice", response_class=StreamingResponse)def generate_voice(message: VoiceMessage = None):print("message",message)return StreamingResponse(audio_stream(message), media_type="audio/mpeg")@app.get("/generate_song")async def generate_song(text: str):25 unmodified lines26272829303132134 unmodified lines16716816917017117217317417517617717817918018118218318418518618718818925 unmodified lines)Last_message=Noneclass PlayLastMusic(BaseModel):'''plays the lastest created music '''Desicion: str = Field(134 unmodified linesexcept Exception as e:raise HTTPException(status_code=500, detail=str(e))@app.get("/generate_voice", response_class=StreamingResponse)@app.post("/generate_voice", response_class=StreamingResponse)def generate_voice(message: VoiceMessage = None):print("message",message)if message is None:message=Last_messageelse:Last_message=messagedef audio_stream():# Generate the audio stream from ElevenLabsfor chunk in Eleven_client.generate(text=message.input, stream=True):yield chunkreturn StreamingResponse(audio_stream(), media_type="audio/mpeg")@app.get("/generate_song")async def generate_song(text: str):
TextGen/router.py+11-7