-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
create_messages.py
165 lines (104 loc) · 3.55 KB
/
create_messages.py
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
from openai import OpenAI
import os
from dotenv import load_dotenv
"""Create your own professional messages with OpenAI for your speaker"""
# Load the environment variables
load_dotenv()
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
def create_holding_message():
message = "One moment please"
response = client.audio.speech.create(
model="tts-1",
voice="fable",
input=message,
)
response.stream_to_file("sounds/holding.mp3")
def create_google_speech_issue():
message = "Sorry, there was an issue reaching Google Speech Recognition, please try again."
response = client.audio.speech.create(
model="tts-1",
voice="fable",
input=message,
)
response.stream_to_file("sounds/google_issue.mp3")
def understand_speech_issue():
message = "Sorry, I didn't quite get that."
response = client.audio.speech.create(
model="tts-1",
voice="fable",
input=message,
)
response.stream_to_file("sounds/understand.mp3")
def stop():
message = "No worries, I'll be here when you need me."
response = client.audio.speech.create(
model="tts-1",
voice="fable",
input=message,
)
response.stream_to_file("sounds/stop.mp3")
def hello():
message = "Welcome, my name is Jeffers, I'm your helpful smart speaker. Just say my name and ask me anything."
response = client.audio.speech.create(
model="tts-1",
voice="fable",
input=message,
)
response.stream_to_file("sounds/hello.mp3")
def create_picovoice_issue():
message = "Sorry, there was an issue with the PicoVoice Service."
response = client.audio.speech.create(
model="tts-1",
voice="fable",
input=message,
)
response.stream_to_file("sounds/picovoice_issue.mp3")
def create_picture_message():
message = "Let me take a look through the camera."
response = client.audio.speech.create(
model="tts-1",
voice="fable",
input=message,
)
response.stream_to_file("sounds/start_camera.mp3")
def start_picture_message():
message = "Hold steady....... I'm taking a photo now...... in ....... 3 ...... 2 ......... 1"
response = client.audio.speech.create(
model="tts-1",
voice="fable",
input=message,
)
response.stream_to_file("sounds/take_photo.mp3")
def agent_search():
message = "Let me do a quick search for you."
response = client.audio.speech.create(
model="tts-1",
voice="fable",
input=message,
)
response.stream_to_file("sounds/agent.mp3")
def audio_issue():
message = "There was an issue opening the PyAudio stream on the device."
response = client.audio.speech.create(
model="tts-1",
voice="fable",
input=message,
)
response.stream_to_file("sounds/audio_issue.mp3")
def tavily_key_error():
message = "I could not find your API key for the Tavily Search Service. Please ensure you update your .env file with a Tavily Search API key in order to use the agent."
response = client.audio.speech.create(
model="tts-1",
voice="fable",
input=message,
)
response.stream_to_file("sounds/tavily_key_error.mp3")
def camera_issue():
message = "Sorry, there was an issue opening Pi Camera."
response = client.audio.speech.create(
model="tts-1",
voice="fable",
input=message,
)
response.stream_to_file("sounds/camera_issue.mp3")
camera_issue()