Aichatbot12321 commited on
Commit
cfa78f9
·
verified ·
1 Parent(s): a39f608

Update server.js via HF Space Commander

Browse files
Files changed (1) hide show
  1. server.js +19 -8
server.js CHANGED
@@ -10598,16 +10598,27 @@ async function handleGeminiLiveTranslate(req, res) {
10598
  let result = null;
10599
  let lastErr = null;
10600
 
10601
- const liveTranslatePrompt = `You are the Gemini 3.5 Live Speech Translation & Transcription Engine.
10602
- The user spoke into their microphone. Your goal is to return clean, articulate, and grammatically polished text.
10603
- 1. Transcribe the spoken audio accurately, resolving any stuttering, repeated syllables, or slurred words into clean, natural sentences.
10604
- 2. If targetLang is requested ("${targetLang}"), translate the spoken message naturally into ${targetLang} with high grammatical accuracy and appropriate punctuation.
10605
- 3. If no translation is needed (or language matches), polish and transcribe directly in the spoken language.
 
 
 
 
 
 
 
 
 
 
 
10606
  STRICT JSON output format:
10607
  {
10608
- "transcript": "Accurate transcription in original spoken language with proper punctuation",
10609
- "translatedText": "Polished text with perfect grammar in ${targetLang}",
10610
- "detectedLanguage": "Name of the detected spoken language"
10611
  }`;
10612
 
10613
  for (const p of geminiProviders) {
 
10598
  let result = null;
10599
  let lastErr = null;
10600
 
10601
+ const isHindi = targetLang.toLowerCase().includes("hi") || targetLang.toLowerCase().includes("hindi");
10602
+ const liveTranslatePrompt = `You are the official Gemini 3.5 Speech-to-Text & Transcribe Engine.
10603
+ Listen carefully to the attached voice recording and transcribe the EXACT words spoken by the user.
10604
+
10605
+ CRITICAL INSTRUCTIONS:
10606
+ 1. Transcribe ONLY the actual audio spoken in the recording.
10607
+ - NEVER output filler sentences, sample texts, or placeholder text (such as "Hello, this is a test of the transcription engine").
10608
+ - If the audio is silent or unintelligible, return an empty string "" for transcript and translatedText.
10609
+ 2. LANGUAGE REQUIREMENT:
10610
+ ${isHindi
10611
+ ? `- The user selected HINDI. You MUST write the output 100% in pure HINDI using DEVANAGARI SCRIPT (हिंदी देवनागरी लिपि).
10612
+ - STRICTLY FORBIDDEN: NEVER write in Hinglish (Roman English letters like "aaj", "kya", "kon", "tarik").
10613
+ - Convert any spoken Hindi or Hinglish directly into proper Devanagari Hindi (e.g., if user says "hello aaj kon sa tarik hi", write "नमस्ते आज कौन सा तारीख है").`
10614
+ : `- Transcribe accurately in ${targetLang} with proper grammar, spelling, and punctuation.`}
10615
+ 3. Maintain high grammar accuracy and proper sentence structure.
10616
+
10617
  STRICT JSON output format:
10618
  {
10619
+ "transcript": "Exact transcription in ${isHindi ? "pure Devanagari Hindi (हिंदी)" : targetLang}",
10620
+ "translatedText": "Polished text in ${isHindi ? "pure Devanagari Hindi (हिंदी)" : targetLang}",
10621
+ "detectedLanguage": "Name of detected spoken language"
10622
  }`;
10623
 
10624
  for (const p of geminiProviders) {