From 03aa74fb3bc0bae7283b33c6c794c048b0a62da2 Mon Sep 17 00:00:00 2001
From: Joby <1151737656@qq.com>
Date: Sun, 30 Jun 2024 05:44:24 +0800
Subject: [PATCH] feat: interrupt function (#1)
---
.gitignore | 1 +
components/StreamingAvatar.tsx | 18 ++++++++++++++++++
package.json | 2 +-
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 8f322f0..9e8dccd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,3 +33,4 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
+.idea
diff --git a/components/StreamingAvatar.tsx b/components/StreamingAvatar.tsx
index c5f6b65..f234122 100644
--- a/components/StreamingAvatar.tsx
+++ b/components/StreamingAvatar.tsx
@@ -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() {
>
+