-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvva_app.py
More file actions
63 lines (51 loc) · 1.85 KB
/
Copy pathvva_app.py
File metadata and controls
63 lines (51 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import os
from dotenv import load_dotenv
from elevenlabs.client import ElevenLabs
from elevenlabs.conversational_ai.conversation import Conversation
from elevenlabs.conversational_ai.default_audio_interface import DefaultAudioInterface
from elevenlabs.types import ConversationConfig
load_dotenv()
AGENT_ID = os.getenv("AGENT_ID")
API_KEY = os.getenv("API_KEY")
user_name = "Yassir Candido"
schedule = "Tomorrow morning I have a study session at 10:00 am to prepare for my coding interview; in the afternoon, I need to work on a project on data analysis using Python; and in the evening, I have a virtual meetup with my coding bootcamp friends at 7:00 pm."
prompt = f"You are a helpful assistant. Your interlocutor has the following schedule: {schedule}."
first_message = f"Hello {user_name}, how can I help you today?"
conversation_override = {
"agent": {
"prompt": {
"prompt": prompt,
},
"first_message": first_message,
},
}
config = ConversationConfig(
conversation_config_override=conversation_override,
extra_body={},
dynamice_variables={},
)
client = ElevenLabs(api_key=API_KEY)
conversation = Conversation(
client,
AGENT_ID,
config=config,
requires_auth=True,
audio_interface=DefaultAudioInterface(),
)
def print_agent_response(response):
print(f"Agent: {response}")
def print_interrupted_response(original, corrected):
print(f"Agent interrupted, truncated response: {corrected}")
def print_user_transcript(transcript):
print(f"User: {transcript}")
conversation = Conversation(
client,
AGENT_ID,
config=config,
requires_auth=True,
audio_interface=DefaultAudioInterface(),
callback_agent_response=print_agent_response,
callback_agent_response_correction=print_interrupted_response,
callback_user_transcript=print_user_transcript,
)
conversation.start_session()