Spaces:
Running
Running
Update server.js via HF Space Commander
Browse files
server.js
CHANGED
|
@@ -10598,16 +10598,27 @@ async function handleGeminiLiveTranslate(req, res) {
|
|
| 10598 |
let result = null;
|
| 10599 |
let lastErr = null;
|
| 10600 |
|
| 10601 |
-
const
|
| 10602 |
-
|
| 10603 |
-
|
| 10604 |
-
|
| 10605 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10606 |
STRICT JSON output format:
|
| 10607 |
{
|
| 10608 |
-
"transcript": "
|
| 10609 |
-
"translatedText": "Polished text
|
| 10610 |
-
"detectedLanguage": "Name of
|
| 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) {
|