From 32f0f62c898cf955b84d729f33398af680b838f6 Mon Sep 17 00:00:00 2001 From: pengu2004 Date: Wed, 13 Aug 2025 20:18:27 +0530 Subject: [PATCH 1/2] Add voice recognition feature to input prompt --- frontend/src/App.js | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/frontend/src/App.js b/frontend/src/App.js index c0fd3f1..51799a9 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -8,10 +8,40 @@ function App() { const [output, setOutput] = useState(""); const [chatLog, setChatLog] = useState([]); const [promptInput, setPromptInput] = useState(""); + const [isListening, setIsListening] = useState(false); const editorRef = useRef(null); const BACKEND_URL = "https://ai-code-editor-2.onrender.com"; // Railway backend URL // Railway backend URL + // Voice recognition setup + const recognitionRef = useRef(null); + + const handleMicClick = () => { + if (!('webkitSpeechRecognition' in window || 'SpeechRecognition' in window)) { + alert('Speech recognition not supported in this browser.'); + return; + } + const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; + if (!recognitionRef.current) { + recognitionRef.current = new SpeechRecognition(); + recognitionRef.current.continuous = false; + recognitionRef.current.interimResults = false; + recognitionRef.current.lang = 'en-US'; + recognitionRef.current.onresult = (event) => { + const transcript = event.results[0][0].transcript; + setPromptInput(prev => prev + (prev ? ' ' : '') + transcript); + setIsListening(false); + }; + recognitionRef.current.onerror = () => { + setIsListening(false); + }; + recognitionRef.current.onend = () => { + setIsListening(false); + }; + } + setIsListening(true); + recognitionRef.current.start(); + }; const handleRun = async () => { try { @@ -98,7 +128,15 @@ function App() { onChange={(e) => setPromptInput(e.target.value)} onKeyDown={(e) => e.key === "Enter" && handleAskAI()} /> - + + From 5a7c33d8a31be4a1c2c6a3756f14b664680ff10a Mon Sep 17 00:00:00 2001 From: pengu2004 Date: Wed, 13 Aug 2025 20:18:46 +0530 Subject: [PATCH 2/2] Enhance system prompt to restrict responses to coding-related queries and ensure code is returned in a copyable format --- backend/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/main.py b/backend/main.py index 755afe2..3c2c19c 100644 --- a/backend/main.py +++ b/backend/main.py @@ -82,7 +82,7 @@ def ask_ai(req: PromptRequest): "model": "deepseek/deepseek-chat-v3-0324", "messages": [ - {"role": "system", "content": "You are Tara, a helpful coding assistant. When asked who you are, always answer 'I am Tara, your helpfull coding assistant'."}, + {"role": "system", "content": "You are Tara, a helpful coding assistant. When asked who you are, always answer 'I am Tara, your helpfull coding assistant'. Don't answer anything that is not related to coding. Also ensure the you return only the code so it can be directly copied to the editor"}, {"role": "user", "content": full_prompt} ]