Skip to content

Commit

Permalink
change synthesizer factory api
Browse files Browse the repository at this point in the history
  • Loading branch information
ajar98 committed Jul 30, 2023
1 parent 4ce40fc commit 28b5587
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion vocode/streaming/agent/restful_user_implemented_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def respond(
) -> Tuple[Optional[str], bool]:
config = self.agent_config.respond
try:
# todo: cache session
# TODO: cache session
async with aiohttp.ClientSession() as session:
payload = RESTfulAgentInput(
human_input=human_input, conversation_id=conversation_id
Expand Down
34 changes: 26 additions & 8 deletions vocode/streaming/synthesizer/factory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from typing import Optional
import typing
import aiohttp

from vocode.streaming.models.synthesizer import (
AzureSynthesizerConfig,
Expand Down Expand Up @@ -31,22 +32,39 @@ def create_synthesizer(
self,
synthesizer_config: SynthesizerConfig,
logger: Optional[logging.Logger] = None,
aiohttp_session: Optional[aiohttp.ClientSession] = None,
):
if isinstance(synthesizer_config, GoogleSynthesizerConfig):
return GoogleSynthesizer(synthesizer_config, logger=logger)
return GoogleSynthesizer(
synthesizer_config, logger=logger, aiohttp_session=aiohttp_session
)
elif isinstance(synthesizer_config, AzureSynthesizerConfig):
return AzureSynthesizer(synthesizer_config, logger=logger)
return AzureSynthesizer(
synthesizer_config, logger=logger, aiohttp_session=aiohttp_session
)
elif isinstance(synthesizer_config, ElevenLabsSynthesizerConfig):
return ElevenLabsSynthesizer(synthesizer_config, logger=logger)
return ElevenLabsSynthesizer(
synthesizer_config, logger=logger, aiohttp_session=aiohttp_session
)
elif isinstance(synthesizer_config, PlayHtSynthesizerConfig):
return PlayHtSynthesizer(synthesizer_config, logger=logger)
return PlayHtSynthesizer(
synthesizer_config, logger=logger, aiohttp_session=aiohttp_session
)
elif isinstance(synthesizer_config, RimeSynthesizerConfig):
return RimeSynthesizer(synthesizer_config, logger=logger)
return RimeSynthesizer(
synthesizer_config, logger=logger, aiohttp_session=aiohttp_session
)
elif isinstance(synthesizer_config, GTTSSynthesizerConfig):
return GTTSSynthesizer(synthesizer_config, logger=logger)
return GTTSSynthesizer(
synthesizer_config, logger=logger, aiohttp_session=aiohttp_session
)
elif isinstance(synthesizer_config, StreamElementsSynthesizerConfig):
return StreamElementsSynthesizer(synthesizer_config, logger=logger)
return StreamElementsSynthesizer(
synthesizer_config, logger=logger, aiohttp_session=aiohttp_session
)
elif isinstance(synthesizer_config, CoquiTTSSynthesizerConfig):
return CoquiTTSSynthesizer(synthesizer_config, logger=logger)
return CoquiTTSSynthesizer(
synthesizer_config, logger=logger, aiohttp_session=aiohttp_session
)
else:
raise Exception("Invalid synthesizer config")

0 comments on commit 28b5587

Please sign in to comment.