@@ -43,7 +43,6 @@ export interface ChatStore {
|
|||||||
develop_mode: boolean;
|
develop_mode: boolean;
|
||||||
whisper_api: string;
|
whisper_api: string;
|
||||||
whisper_key: string;
|
whisper_key: string;
|
||||||
audioDeviceID: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const _defaultAPIEndpoint = "https://api.openai.com/v1/chat/completions";
|
const _defaultAPIEndpoint = "https://api.openai.com/v1/chat/completions";
|
||||||
@@ -81,7 +80,6 @@ const newChatStore = (
|
|||||||
develop_mode: getDefaultParams("dev", dev),
|
develop_mode: getDefaultParams("dev", dev),
|
||||||
whisper_api: getDefaultParams("whisper-api", whisper_api),
|
whisper_api: getDefaultParams("whisper-api", whisper_api),
|
||||||
whisper_key: getDefaultParams("whisper-key", whisper_key),
|
whisper_key: getDefaultParams("whisper-key", whisper_key),
|
||||||
audioDeviceID: "",
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -249,8 +249,6 @@ export default (props: {
|
|||||||
const [totalCost, setTotalCost] = useState(getTotalCost());
|
const [totalCost, setTotalCost] = useState(getTotalCost());
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const { langCode, setLangCode } = useContext(langCodeContext);
|
const { langCode, setLangCode } = useContext(langCodeContext);
|
||||||
// type is MediaDeviceInfo
|
|
||||||
const [devices, setDevices] = useState([] as MediaDeviceInfo[]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleKeyPress = (event: any) => {
|
const handleKeyPress = (event: any) => {
|
||||||
@@ -411,52 +409,6 @@ export default (props: {
|
|||||||
help="用于 Whisper 服务的 key,默认为 上方使用的OPENAI key,可在此单独配置专用key"
|
help="用于 Whisper 服务的 key,默认为 上方使用的OPENAI key,可在此单独配置专用key"
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<p className="flex justify-between">
|
|
||||||
<label className="m-2 p-2">{Tr("Audio Device")}</label>
|
|
||||||
{devices.length === 0 && (
|
|
||||||
<button
|
|
||||||
className="p-2 m-2 rounded bg-emerald-500"
|
|
||||||
onClick={async () => {
|
|
||||||
const ds: MediaDeviceInfo[] = (
|
|
||||||
await navigator.mediaDevices.enumerateDevices()
|
|
||||||
).filter((device) => device.kind === "audioinput");
|
|
||||||
|
|
||||||
setDevices([...ds]);
|
|
||||||
console.log("devices", ds);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{props.chatStore.audioDeviceID
|
|
||||||
? props.chatStore.audioDeviceID
|
|
||||||
: Tr("default")}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
{devices.length > 0 && (
|
|
||||||
<select
|
|
||||||
value={
|
|
||||||
props.chatStore.audioDeviceID
|
|
||||||
? props.chatStore.audioDeviceID
|
|
||||||
: "default"
|
|
||||||
}
|
|
||||||
onChange={(event: any) => {
|
|
||||||
const value = event.target.value;
|
|
||||||
if (!value || value == "default") {
|
|
||||||
props.chatStore.audioDeviceID = "";
|
|
||||||
props.setChatStore({ ...props.chatStore });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
props.chatStore.audioDeviceID = value;
|
|
||||||
props.setChatStore({ ...props.chatStore });
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<option value={"default"}>{Tr("default")}</option>
|
|
||||||
{devices.map((device) => (
|
|
||||||
<option value={device.deviceId}>{device.deviceId}</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<p className="m-2 p-2">
|
<p className="m-2 p-2">
|
||||||
{Tr("Accumulated cost in all sessions")} ${totalCost.toFixed(4)}
|
{Tr("Accumulated cost in all sessions")} ${totalCost.toFixed(4)}
|
||||||
|
|||||||
Reference in New Issue
Block a user