Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

languages

Murtaza Nasird4ef05887d4c
diff --git a/app.py b/app.py
index dc5a8a6a..de3a38b1 100644
--- a/app.py
+++ b/app.py
@@ -217,6 +217,8 @@ app.logger.info(f"Using Whisper API at: {transcription_base_url}")
# --- Background Transcription & Summarization Task ---
def transcribe_audio_task(app_context, recording_id, filepath, original_filename):
"""Runs the transcription and summarization in a background thread."""
+ output_language = os.environ.get("OUTPUT_LANGUAGE", None) # Get preferred output language
+
with app_context: # Need app context for db operations in thread
recording = db.session.get(Recording, recording_id)
if not recording:
@@ -291,7 +293,7 @@ Transcription:
\"\"\"
Respond STRICTLY with a JSON object containing two keys: "title" (a short, descriptive title, max 6 words without using words introductory words and phrases like brief, "discussion on", "Meeting about" etc.) and "summary" (a paragraph summarizing the key points, max 150 words). The title should get to the point without inroductory phrases as we have very little space to show the title.
-
+{f"Please provide the title and summary in {output_language}." if output_language else ""}
Example Format:
{{
"title": "Q3 Results for SPERO Program",
@@ -299,13 +301,17 @@ Example Format:
}}
JSON Response:""" # The prompt guides the model towards the desired output
+
+ system_message_content = "You are an AI assistant that generates titles and summaries for meeting transcripts. Respond only with the requested JSON object."
+ if output_language:
+ system_message_content += f" Ensure your response (both title and summary) is in {output_language}."
try:
# Use the OpenRouter client configured earlier
completion = client.chat.completions.create(
model=TEXT_MODEL_NAME,
messages=[
- {"role": "system", "content": "You are an AI assistant that generates titles and summaries for meeting transcripts. Respond only with the requested JSON object."},
+ {"role": "system", "content": system_message_content},
{"role": "user", "content": prompt_text}
],
temperature=0.5, # Adjust temperature as needed
@@ -409,7 +415,13 @@ def chat_with_transcription():
return jsonify({'error': 'Chat service is not available (OpenRouter client not configured)'}), 503
# Prepare the system prompt with the transcription
- system_prompt = f"""You are a professional meeting analyst working with Murtaza Nasir, Assistant Professor at Wichita State University. Analyze the following meeting information and respond to the specific request.
+ output_language_chat = os.environ.get("OUTPUT_LANGUAGE", None) # Get preferred output language for chat
+
+ language_instruction = ""
+ if output_language_chat:
+ language_instruction = f"Please provide all your responses in {output_language_chat}."
+
+ system_prompt = f"""You are a professional meeting analyst working with Murtaza Nasir, Assistant Professor at Wichita State University. {language_instruction} Analyze the following meeting information and respond to the specific request.
Following are the meeting participants and their roles:
{recording.participants or "No specific participants information provided."}
diff --git a/docker-compose.example.yml b/docker-compose.example.yml
index 6bc91e3e..a67d6f5b 100644
--- a/docker-compose.example.yml
+++ b/docker-compose.example.yml
@@ -38,6 +38,7 @@ services:
- TRANSCRIPTION_API_KEY=your_transcription_api_key_here
- WHISPER_MODEL=Systran/faster-distil-whisper-large-v3
- TRANSCRIPTION_LANGUAGE= # Optional: Specify ISO-639-1 language code (e.g., en, es, fr, zh for Chinese). Leave empty for auto-detection.
+ - OUTPUT_LANGUAGE= # Optional: Specify desired language for LLM outputs (e.g., English, Spanish, Chinese). Leave empty for English default.
# Application settings
- ALLOW_REGISTRATION=false
diff --git a/readme.md b/readme.md
index 765f53b2..c8f25c7f 100644
--- a/readme.md
+++ b/readme.md
@@ -96,6 +96,7 @@ The easiest way to deploy Speakr is using Docker and docker compose.
- TRANSCRIPTION_API_KEY=your_transcription_api_key_here
- WHISPER_MODEL=Systran/faster-distil-whisper-large-v3
- TRANSCRIPTION_LANGUAGE= # Optional: Specify ISO-639-1 language code (e.g., en, es, fr, zh for Chinese). Leave empty for auto-detection.
+ - OUTPUT_LANGUAGE= # Optional: Specify desired language for LLM outputs (e.g., English, Spanish, Chinese). Leave empty for English default.
# Application settings
- ALLOW_REGISTRATION=false
@@ -358,6 +359,7 @@ Configuration is primarily handled through environment variables in the `docker-
* `TRANSCRIPTION_API_KEY`: **Required.** Your API key for the transcription endpoint. For local endpoints, this might be a specific string like "none" or "NA". Check your endpoint's documentation.
* `WHISPER_MODEL`: *Optional.* The specific model name your transcription endpoint uses/expects (e.g., `Systran/faster-distil-whisper-large-v3`). Check your endpoint's requirements.
* `TRANSCRIPTION_LANGUAGE`: *Optional.* The language of the input audio. Supplying the input language in ISO-639-1 format (e.g., `en` for English, `es` for Spanish) will improve transcription accuracy and latency. If not set, the transcription service will attempt to auto-detect the language.
+* `OUTPUT_LANGUAGE`: *Optional.* The desired language for the generated titles, summaries, and chat responses (e.g., "English", "Spanish", "Chinese"). If not set, outputs will typically be in the language of the transcription or English. Ensure your chosen `TEXT_MODEL_NAME` supports the desired output language.
* `SECRET_KEY`: **Required.** A long, random string used by Flask for session security. The `setup.sh` script generates one if it's missing.
* `ALLOW_REGISTRATION`: *Optional.* Set to `false` to prevent new users from registering via the web UI. Defaults to `true`.