add voice configs + transcriber configs

This commit is contained in:
Ajay Raj 2023-03-12 00:29:12 -08:00
commit 1807fbef0d
6 changed files with 62 additions and 12 deletions

View file

@ -2,6 +2,9 @@ from fastapi import FastAPI, Response, Form
from typing import Optional
import requests
import uvicorn
from vocode.models.synthesizer import SynthesizerConfig
from vocode.models.transcriber import TranscriberConfig
from .. import api_key, BASE_URL
from ..models.agent import AgentConfig
@ -12,9 +15,15 @@ VOCODE_INBOUND_CALL_URL = f"https://{BASE_URL}/create_inbound_call"
class InboundCallServer:
def __init__(
self, agent_config: AgentConfig, response_on_rate_limit: Optional[str] = None
self,
agent_config: AgentConfig,
transcriber_config: Optional[TranscriberConfig] = None,
synthesizer_config: Optional[SynthesizerConfig] = None,
response_on_rate_limit: Optional[str] = None,
):
self.agent_config = agent_config
self.transcriber_config = transcriber_config
self.synthesizer_config = synthesizer_config
self.app = FastAPI()
self.app.post("/vocode")(self.handle_call)
self.response_on_rate_limit = (
@ -27,7 +36,10 @@ class InboundCallServer:
VOCODE_INBOUND_CALL_URL,
headers={"Authorization": f"Bearer {api_key}"},
json=CreateInboundCall(
agent_config=self.agent_config, twilio_sid=twilio_sid
agent_config=self.agent_config,
twilio_sid=twilio_sid,
transcriber_config=self.transcriber_config,
synthesizer_config=self.synthesizer_config,
).dict(),
)
if response.status_code == 429:

View file

@ -1,27 +1,38 @@
from typing import Optional
from vocode.models.agent import AgentConfig
from vocode.models.synthesizer import SynthesizerConfig
from vocode.models.transcriber import TranscriberConfig
from ..models.telephony import CallEntity, CreateOutboundCall
import requests
from .. import api_key, BASE_URL
VOCODE_OUTBOUND_CALL_URL = f"https://{BASE_URL}/create_outbound_call"
class OutboundCall:
def __init__(self, recipient: CallEntity, caller: CallEntity, agent_config):
class OutboundCall:
def __init__(
self,
recipient: CallEntity,
caller: CallEntity,
agent_config: AgentConfig,
transcriber_config: Optional[TranscriberConfig] = None,
synthesizer_config: Optional[SynthesizerConfig] = None,
):
self.recipient = recipient
self.caller = caller
self.agent_config = agent_config
self.transcriber_config = transcriber_config
self.synthesizer_config = synthesizer_config
def start(self):
return requests.post(
VOCODE_OUTBOUND_CALL_URL,
headers={
"Authorization": f"Bearer {api_key}"
},
headers={"Authorization": f"Bearer {api_key}"},
json=CreateOutboundCall(
recipient=self.recipient,
caller=self.caller,
agent_config=self.agent_config
).dict()
agent_config=self.agent_config,
transcriber_config=self.transcriber_config,
synthesizer_config=self.synthesizer_config,
).dict(),
)