mirror of
https://github.com/ijaric/voice_assistant.git
synced 2025-07-12 18:23:25 +00:00
feat(temp): [#46] add tts mock
This commit is contained in:
parent
82c5214ae3
commit
0e7e1753f1
|
@ -4,14 +4,18 @@ import io
|
||||||
import fastapi
|
import fastapi
|
||||||
|
|
||||||
import lib.stt.services as stt_services
|
import lib.stt.services as stt_services
|
||||||
|
# import lib.tts.services as tts_service
|
||||||
|
# import lib.models as models
|
||||||
|
|
||||||
|
|
||||||
class VoiceResponseHandler:
|
class VoiceResponseHandler:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
stt: stt_services.SpeechService,
|
stt: stt_services.SpeechService,
|
||||||
|
# tts: tts_service.TTSService,
|
||||||
):
|
):
|
||||||
self.stt = stt
|
self.stt = stt
|
||||||
|
# self.tts = tts
|
||||||
self.router = fastapi.APIRouter()
|
self.router = fastapi.APIRouter()
|
||||||
self.router.add_api_route(
|
self.router.add_api_route(
|
||||||
"/",
|
"/",
|
||||||
|
@ -31,4 +35,10 @@ class VoiceResponseHandler:
|
||||||
# TODO: Добавить обработку текста через клиента openai
|
# TODO: Добавить обработку текста через клиента openai
|
||||||
# TODO: Добавить синтез речи через клиента tts
|
# TODO: Добавить синтез речи через клиента tts
|
||||||
# TODO: Заменить заглушку на реальный ответ
|
# TODO: Заменить заглушку на реальный ответ
|
||||||
|
# response = await self.tts.get_audio_as_bytes(
|
||||||
|
# models.TTSCreateRequestModel(
|
||||||
|
# text=voice_text,
|
||||||
|
# )
|
||||||
|
# )
|
||||||
|
# return fastapi.responses.StreamingResponse(io.BytesIO(response.audio_content), media_type="audio/ogg")
|
||||||
return fastapi.responses.StreamingResponse(io.BytesIO(voice), media_type="audio/ogg")
|
return fastapi.responses.StreamingResponse(io.BytesIO(voice), media_type="audio/ogg")
|
||||||
|
|
|
@ -88,7 +88,10 @@ class Application:
|
||||||
liveness_probe_handler = api_v1_handlers.basic_router
|
liveness_probe_handler = api_v1_handlers.basic_router
|
||||||
|
|
||||||
# TODO: объявить сервисы tts и openai и добавить их в voice_response_handler
|
# TODO: объявить сервисы tts и openai и добавить их в voice_response_handler
|
||||||
voice_response_handler = api_v1_handlers.VoiceResponseHandler(stt=stt_service).router
|
voice_response_handler = api_v1_handlers.VoiceResponseHandler(
|
||||||
|
stt=stt_service,
|
||||||
|
# tts=tts_service, # TODO
|
||||||
|
).router
|
||||||
|
|
||||||
logger.info("Creating application")
|
logger.info("Creating application")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user