Compare commits

...

1 Commits

Author SHA1 Message Date
raojianb
051d81f97b feat: interrupt function 2024-06-29 14:43:59 -07:00
3 changed files with 20 additions and 1 deletions

1
.gitignore vendored
View File

@@ -33,3 +33,4 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
.idea

View File

@@ -131,6 +131,16 @@ export default function StreamingAvatar() {
setInitialized(true);
}
async function handleInterrupt() {
if (!initialized || !avatar.current) {
setDebug('Avatar API not initialized');
return;
}
await avatar.current.interrupt({ interruptRequest: { sessionId: data?.sessionId } }).catch((e) => {
setDebug(e.message);
});
}
async function endSession() {
if (!initialized || !avatar.current) {
setDebug("Avatar API not initialized");
@@ -249,6 +259,14 @@ export default function StreamingAvatar() {
>
<track kind="captions" />
</video>
<Button
size="md"
onClick={handleInterrupt}
className="bg-gradient-to-tr from-indigo-500 to-indigo-300 absolute bottom-20 right-3 text-white rounded-lg"
variant="shadow"
>
Interrupt
</Button>
<Button
size="md"
onClick={endSession}

View File

@@ -10,7 +10,7 @@
},
"dependencies": {
"@ai-sdk/openai": "^0.0.34",
"@heygen/streaming-avatar": "^1.0.10",
"@heygen/streaming-avatar": "^1.0.11",
"@nextui-org/button": "2.0.34",
"@nextui-org/code": "2.0.29",
"@nextui-org/input": "2.2.2",