create-local-voice-agent 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -38,8 +38,20 @@ function VoiceAssistantUI() {
|
|
|
38
38
|
export default function Home() {
|
|
39
39
|
const [token, setToken] = useState<string | null>(null);
|
|
40
40
|
const [error, setError] = useState<string | null>(null);
|
|
41
|
+
const [connected, setConnected] = useState(false);
|
|
42
|
+
const [serverUrl, setServerUrl] = useState("");
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (typeof window !== "undefined") {
|
|
46
|
+
let envUrl = process.env.NEXT_PUBLIC_LIVEKIT_URL;
|
|
47
|
+
// Aggressively override if the baked-in variable is empty, localhost, or 127.0.0.1
|
|
48
|
+
if (!envUrl || envUrl.includes("127.0.0.1") || envUrl.includes("localhost")) {
|
|
49
|
+
const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
|
|
50
|
+
envUrl = `${protocol}//${window.location.hostname}:7880`;
|
|
51
|
+
}
|
|
52
|
+
setServerUrl(envUrl);
|
|
53
|
+
}
|
|
54
|
+
}, []);
|
|
43
55
|
|
|
44
56
|
useEffect(() => {
|
|
45
57
|
async function fetchToken() {
|
|
@@ -75,16 +87,29 @@ export default function Home() {
|
|
|
75
87
|
return (
|
|
76
88
|
<main style={{ padding: "2rem", textAlign: "center" }}>
|
|
77
89
|
<h1><%= projectName %></h1>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
{!connected && (
|
|
91
|
+
<button
|
|
92
|
+
type="button"
|
|
93
|
+
onClick={() => setConnected(true)}
|
|
94
|
+
disabled={!serverUrl}
|
|
95
|
+
style={{ padding: "0.75rem 1.25rem", marginBottom: "1rem" }}
|
|
96
|
+
>
|
|
97
|
+
Start Conversation
|
|
98
|
+
</button>
|
|
99
|
+
)}
|
|
100
|
+
{serverUrl ? (
|
|
101
|
+
<LiveKitRoom
|
|
102
|
+
serverUrl={serverUrl}
|
|
103
|
+
token={token}
|
|
104
|
+
connect={connected}
|
|
105
|
+
audio={true}
|
|
106
|
+
>
|
|
107
|
+
<VoiceAssistantUI />
|
|
108
|
+
<RoomAudioRenderer />
|
|
109
|
+
</LiveKitRoom>
|
|
110
|
+
) : (
|
|
111
|
+
<p>Detecting LiveKit server URL...</p>
|
|
112
|
+
)}
|
|
87
113
|
</main>
|
|
88
114
|
);
|
|
89
115
|
}
|
|
90
|
-
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"react": "^19.0.0",
|
|
13
13
|
"react-dom": "^19.0.0",
|
|
14
14
|
"@livekit/components-react": "^2.0.0",
|
|
15
|
+
"@livekit/components-styles": "^1.1.4",
|
|
15
16
|
"livekit-client": "^2.0.0",
|
|
16
17
|
"livekit-server-sdk": "^2.0.0"
|
|
17
18
|
},
|
|
@@ -21,4 +22,3 @@
|
|
|
21
22
|
"typescript": "^5.0.0"
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
|