You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+10
Original file line number
Diff line number
Diff line change
@@ -74,3 +74,13 @@ node index.js
74
74
```
75
75
## Test the app
76
76
With the development server running, call the phone number you purchases in the **Prerequisites**. After the introduction, you should be able to talk to the AI Assistant. Have fun!
77
+
78
+
## Special features
79
+
80
+
### Have the AI speak first
81
+
To have the AI voice assistant talk before the user, uncomment the line `// sendInitialConversationItem();`. The initial greeting is controlled in `sendInitialConversationItem`.
82
+
83
+
### Interrupt handling/AI preemption
84
+
When the user speaks and OpenAI sends `input_audio_buffer.speech_started`, the code will clear the Twilio Media Streams buffer and send OpenAI `conversation.item.truncate`.
85
+
86
+
Depending on your application's needs, you may want to use the [`input_audio_buffer.speech_stopped`](https://platform.openai.com/docs/api-reference/realtime-server-events/input-audio-buffer-speech-stopped) event, instead.
// Uncomment the following line to have AI speak first:
97
+
// sendInitialConversationItem();
98
+
};
99
+
100
+
constsendInitialConversationItem=()=>{
101
+
constinitialConversationItem={
102
+
type: 'conversation.item.create',
103
+
item: {
104
+
type: 'message',
105
+
role: 'user',
106
+
content: [
107
+
{
108
+
type: 'input_text',
109
+
text: 'Greet the user with "Hello there! I am an AI voice assistant powered by Twilio and the OpenAI Realtime API. You can ask me for facts, jokes, or anything you can imagine. How can I help you?"'
0 commit comments