added open mic config
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
from daily_helpers import create_room, get_token, check_room_url
|
from daily_helpers import create_room, get_token, check_room_url
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
import atexit
|
import atexit
|
||||||
@@ -129,7 +128,11 @@ async def start_bot(request: Request) -> JSONResponse:
|
|||||||
# Grab a token for the user to join with
|
# Grab a token for the user to join with
|
||||||
user_token = get_token(room_url)
|
user_token = get_token(room_url)
|
||||||
|
|
||||||
return JSONResponse({"bot_id": proc.pid, "room_url": room_url, "token": user_token})
|
return JSONResponse({
|
||||||
|
"bot_id": proc.pid,
|
||||||
|
"room_url": room_url,
|
||||||
|
"token": user_token,
|
||||||
|
"config": {"open_mic": True}})
|
||||||
|
|
||||||
|
|
||||||
# ----------------- Main ----------------- #
|
# ----------------- Main ----------------- #
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export default function App() {
|
|||||||
|
|
||||||
const [state, setState] = useState<State>("idle");
|
const [state, setState] = useState<State>("idle");
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
//const [room, setRoom] = useState<string | null>(null);
|
const [config, setConfig] = useState<{ open_mic?: boolean }>({});
|
||||||
|
|
||||||
async function start() {
|
async function start() {
|
||||||
if (!daily) return;
|
if (!daily) return;
|
||||||
@@ -45,6 +45,7 @@ export default function App() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
data = await res.json();
|
data = await res.json();
|
||||||
|
setConfig(data.config || {});
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
setError(data.detail);
|
setError(data.detail);
|
||||||
@@ -85,7 +86,7 @@ export default function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state === "connected") {
|
if (state === "connected") {
|
||||||
return <Session onLeave={() => leave()} />;
|
return <Session onLeave={() => leave()} openMic={config?.open_mic} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const status_text = {
|
const status_text = {
|
||||||
|
|||||||
@@ -9,11 +9,21 @@ import UserMicBubble from "../UserMicBubble";
|
|||||||
|
|
||||||
import styles from "./styles.module.css";
|
import styles from "./styles.module.css";
|
||||||
|
|
||||||
export const Session: React.FC<{ onLeave: () => void }> = ({ onLeave }) => {
|
interface SessionProps {
|
||||||
|
onLeave: () => void;
|
||||||
|
openMic?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Session: React.FC<SessionProps> = ({
|
||||||
|
onLeave,
|
||||||
|
openMic = false,
|
||||||
|
}) => {
|
||||||
const daily = useDaily();
|
const daily = useDaily();
|
||||||
const [showDevices, setShowDevices] = useState(false);
|
const [showDevices, setShowDevices] = useState(false);
|
||||||
const modalRef = useRef<HTMLDialogElement>(null);
|
const modalRef = useRef<HTMLDialogElement>(null);
|
||||||
const [talkState, setTalkState] = useState<"user" | "assistant">("assistant");
|
const [talkState, setTalkState] = useState<"user" | "assistant" | "open">(
|
||||||
|
openMic ? "open" : "assistant"
|
||||||
|
);
|
||||||
|
|
||||||
useAppMessage({
|
useAppMessage({
|
||||||
onAppMessage: (e) => {
|
onAppMessage: (e) => {
|
||||||
@@ -52,7 +62,7 @@ export const Session: React.FC<{ onLeave: () => void }> = ({ onLeave }) => {
|
|||||||
|
|
||||||
<div className={styles.agentContainer}>
|
<div className={styles.agentContainer}>
|
||||||
<Agent />
|
<Agent />
|
||||||
<UserMicBubble active={talkState === "user"} />
|
<UserMicBubble openMic={openMic} active={talkState !== "assistant"} />
|
||||||
<DailyAudio />
|
<DailyAudio />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -108,3 +108,12 @@
|
|||||||
background: var(--color-orange-400);
|
background: var(--color-orange-400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.statusGreen {
|
||||||
|
color: var(--color-green-800);
|
||||||
|
background: var(--color-green-100);
|
||||||
|
|
||||||
|
> span {
|
||||||
|
background: var(--color-green-400);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,9 +35,10 @@ const AudioIndicatorBubble: React.FC = () => {
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
active: boolean;
|
active: boolean;
|
||||||
|
openMic: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function UserMicBubble({ active }: Props) {
|
export default function UserMicBubble({ active, openMic = false }: Props) {
|
||||||
/*
|
/*
|
||||||
const [transcription, setTranscription] = useState<string[]>([]);
|
const [transcription, setTranscription] = useState<string[]>([]);
|
||||||
useAppMessage({
|
useAppMessage({
|
||||||
@@ -56,13 +57,13 @@ export default function UserMicBubble({ active }: Props) {
|
|||||||
return () => clearTimeout(t);
|
return () => clearTimeout(t);
|
||||||
}, [active]);*/
|
}, [active]);*/
|
||||||
|
|
||||||
|
const cx = openMic ? styles.micIconOpen : active && styles.micIconActive;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`${styles.bubbleContainer} ${active ? styles.active : ""}`}>
|
<div className={`${styles.bubbleContainer}`}>
|
||||||
<div
|
<div className={`${styles.micIcon} ${cx}`}>
|
||||||
className={`${styles.micIcon} ${active ? styles.micIconActive : ""}`}
|
{!openMic && !active ? <MicOff size={42} /> : <Mic size={42} />}
|
||||||
>
|
{(openMic || active) && <AudioIndicatorBubble />}
|
||||||
{active ? <Mic size={42} /> : <MicOff size={42} />}
|
|
||||||
{active && <AudioIndicatorBubble />}
|
|
||||||
</div>
|
</div>
|
||||||
<footer className={styles.transcript}></footer>
|
<footer className={styles.transcript}></footer>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
.active::after {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bubbleContainer {
|
.bubbleContainer {
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -56,6 +52,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.micIconOpen {
|
||||||
|
background-color: var(--color-gray-500);
|
||||||
|
background-image: radial-gradient(
|
||||||
|
var(--color-gray-500),
|
||||||
|
var(--color-gray-600)
|
||||||
|
);
|
||||||
|
border: 6px solid color-mix(in srgb, var(--color-gray-200), transparent 60%);
|
||||||
|
outline: 6px solid color-mix(in srgb, var(--color-gray-400), transparent 70%);
|
||||||
|
}
|
||||||
|
|
||||||
.micIconActive {
|
.micIconActive {
|
||||||
background-color: var(--color-green-500);
|
background-color: var(--color-green-500);
|
||||||
background-image: radial-gradient(
|
background-image: radial-gradient(
|
||||||
@@ -67,6 +73,7 @@
|
|||||||
animation: pulse 2s infinite ease-in-out;
|
animation: pulse 2s infinite ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.micIconOpen svg,
|
||||||
.micIconActive svg {
|
.micIconActive svg {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user