Skip to content

Commit 69d2514

Browse files
feat: Using local VAD concept (#26)
* fix: remove erroneous greetings * feat: introducing local VAD concept * Fix next.config.js for vad (#28) * feat: using VAD to barge-in * feat: rescue some of the old barge-in code and fail-safe * feat: use react-nowplaying for audio playback * fix: runtime order of code was confusing * chore: add dev container file [no ci] * fix: only barge-in or fail-safe if the mic is on * fix: play/pause works * fix: controls working for audio and text barge-in and playback * feat: open mic as default * feat: failsafe and barge-in rebuilt using selero VAD --------- Co-authored-by: Ricky Samore <[email protected]>
1 parent c02cb1c commit 69d2514

23 files changed

+1278
-477
lines changed

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: "devcontainers"
10+
directory: "/"
11+
schedule:
12+
interval: weekly

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ next-env.d.ts
4040
.contentlayer
4141

4242
# vscode
43-
.vscode
43+
.vscode
44+
45+
# container
46+
.devcontainer

app/components/AgentAvatar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Avatar } from "@nextui-org/react";
22
import { DgSvg } from "./DgSvg";
33
import { Message } from "ai/react";
44
import { useMessageData } from "../context/MessageMetadata";
5-
import { usePlayQueue } from "../context/PlayQueue";
5+
import { useAudioStore } from "../context/AudioStore";
66
import { voiceMap } from "../context/Deepgram";
77

88
export const AgentAvatar = ({
@@ -12,10 +12,10 @@ export const AgentAvatar = ({
1212
message: Message;
1313
className?: string;
1414
}) => {
15-
const { playQueue } = usePlayQueue();
15+
const { audioStore } = useAudioStore();
1616
const { messageData } = useMessageData();
1717

18-
const foundAudio = playQueue.findLast((item) => item.id === message.id);
18+
const foundAudio = audioStore.findLast((item) => item.id === message.id);
1919
const foundData = messageData.findLast((item) => item.id === message.id);
2020

2121
if (foundAudio?.model) {

app/components/Controls.tsx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import { useCallback, useMemo } from "react";
2-
import { isTablet, isMobile } from "react-device-detect";
1+
import { Message } from "ai/react";
2+
import { Tooltip } from "@nextui-org/react";
3+
import { useCallback, useEffect } from "react";
4+
5+
import { Download } from "./Download";
36
import { MicrophoneIcon } from "./icons/MicrophoneIcon";
47
import { SendIcon } from "./icons/SendIcon";
5-
import { useNowPlaying } from "../context/NowPlaying";
6-
import { usePlayQueue } from "../context/PlayQueue";
7-
import { useMicrophone } from "../context/Microphone";
8-
import { Download } from "./Download";
9-
import { Message } from "ai/react";
108
import { Settings } from "./Settings";
11-
import { Tooltip } from "@nextui-org/react";
9+
import { useMicrophone } from "../context/Microphone";
10+
import { useNowPlaying } from "react-nowplaying";
1211

1312
export const Controls = ({
1413
input,
@@ -23,6 +22,11 @@ export const Controls = ({
2322
}) => {
2423
const { startMicrophone, stopMicrophone, microphoneOpen } = useMicrophone();
2524

25+
useEffect(() => {
26+
startMicrophone();
27+
// eslint-disable-next-line react-hooks/exhaustive-deps
28+
}, [])
29+
2630
const microphoneToggle = useCallback(
2731
async (e: Event) => {
2832
e.preventDefault();
@@ -36,20 +40,15 @@ export const Controls = ({
3640
[microphoneOpen, startMicrophone, stopMicrophone]
3741
);
3842

39-
const { updateItem } = usePlayQueue();
40-
const { nowPlaying, clearNowPlaying, player } = useNowPlaying();
43+
const { stop: stopAudio } = useNowPlaying();
4144

4245
const submitter = useCallback(
4346
(e: any) => {
44-
if (nowPlaying) {
45-
player?.pause();
46-
updateItem(nowPlaying.id, { played: true });
47-
clearNowPlaying();
48-
}
4947
handleSubmit(e);
48+
stopAudio();
5049
},
51-
// eslint-disable-next-line react-hooks/exhaustive-deps
52-
[clearNowPlaying, handleSubmit, nowPlaying, updateItem]
50+
// eslint-disable-next-line react-hooks/exhaustive-deps
51+
[stopAudio, handleSubmit]
5352
);
5453

5554
return (

0 commit comments

Comments
 (0)