From 0ae104a4f08b4ad8ba18175f744fa0aaf13562cc Mon Sep 17 00:00:00 2001 From: sageTheDM Date: Mon, 30 Sep 2024 07:46:40 +0200 Subject: [PATCH 1/2] Small refactoring --- app/backend/InputOutputHandler.tsx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/backend/InputOutputHandler.tsx b/app/backend/InputOutputHandler.tsx index 0a1d891..923d11c 100644 --- a/app/backend/InputOutputHandler.tsx +++ b/app/backend/InputOutputHandler.tsx @@ -196,21 +196,21 @@ const InputOutputBackend: React.FC = () => { ffmpegRef.current = new FFmpeg() await ffmpegRef.current.load() } - } + } - const convertOggToWav = async (oggFile: File | Blob) => { - await loadFFmpeg() + const convertOggToWav = async (oggFile: File | Blob) => { + await loadFFmpeg() - const ffmpeg = ffmpegRef.current! + const ffmpeg = ffmpegRef.current! - await ffmpeg.writeFile("input.ogg", await fetchFile(oggFile)) - await ffmpeg.exec(["-i", "input.ogg", "output.wav"]) - const wavData = await ffmpeg.readFile("output.wav") - console.log(wavData); - const wavBlob = new Blob([wavData], { type: "audio/wav" }) - audioRef.current = URL.createObjectURL(wavBlob) - return wavBlob - } + await ffmpeg.writeFile("input.ogg", await fetchFile(oggFile)) + await ffmpeg.exec(["-i", "input.ogg", "output.wav"]) + const wavData = await ffmpeg.readFile("output.wav") + console.log(wavData); + const wavBlob = new Blob([wavData], { type: "audio/wav" }) + audioRef.current = URL.createObjectURL(wavBlob) + return wavBlob + } const stopRecording = () => { mediaRecorderRef.current?.stop() From 8fd4b77ecd926d2cb395ebdf17718ffeaa6c3d12 Mon Sep 17 00:00:00 2001 From: sageTheDM Date: Mon, 30 Sep 2024 08:39:55 +0200 Subject: [PATCH 2/2] System Prompt changes --- app/backend/InputOutputHandler.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/backend/InputOutputHandler.tsx b/app/backend/InputOutputHandler.tsx index 7270ecb..47a6e1f 100644 --- a/app/backend/InputOutputHandler.tsx +++ b/app/backend/InputOutputHandler.tsx @@ -33,14 +33,16 @@ const InputOutputBackend: React.FC = () => { You use the time format ${timeFormat}. You use the date format ${dateFormat} for all references of dates. You use the ${preferredMeasurement} system. You use the currency ${preferredCurrency}. - You will anwser in ${preferredLanguage}.` + You will only answer in the language (you will receive the country code) ${preferredLanguage}. + But in the case the user specifically states to answer in an other language do that speaking in a + nother language is not stating you should answer in that language. Additionally do not translate your answer into multiple languages` },{ role: "assistant", content: "Hello! How can I help you?" }]) const [liveMessage, setLiveMessage] = useState("") const [inputMessage, setInputMessage] = useState("") const [inputDisabled, setInputDisabled] = useState(false) const [isRecording, setIsRecording] = useState(false) const [audioURL, setAudioURL] = useState(null) - const mediaRecorderRef = useRef(null) + const mediaRecorderRef = useRef(null) const audioChunks = useRef([])