Skip to content

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

Python

add language

Murtaza Nasirb4c19cd8b72c
diff --git a/app.py b/app.py
index 55b0c5bb..dc5a8a6a 100644
--- a/app.py
+++ b/app.py
@@ -243,11 +243,22 @@ def transcribe_audio_task(app_context, recording_id, filepath, original_filename
)
# Get the Whisper model name from environment variables
whisper_model = os.environ.get("WHISPER_MODEL", "Systran/faster-distil-whisper-large-v3")
- transcript = transcription_client.audio.transcriptions.create(
- model=whisper_model, # Use model from environment variables
- file=audio_file,
- language="en" # Specify language if known
- )
+
+ # Get the transcription language from environment variables
+ transcription_language = os.environ.get("TRANSCRIPTION_LANGUAGE", None) # Default to None if not set
+
+ transcription_params = {
+ "model": whisper_model,
+ "file": audio_file
+ }
+
+ if transcription_language:
+ transcription_params["language"] = transcription_language
+ app.logger.info(f"Using transcription language: {transcription_language}")
+ else:
+ app.logger.info("Transcription language not set, using auto-detection or service default.")
+
+ transcript = transcription_client.audio.transcriptions.create(**transcription_params)
recording.transcription = transcript.text
app.logger.info(f"Transcription completed for recording {recording_id}. Text length: {len(recording.transcription)}")
# Don't commit yet, proceed to summarization
diff --git a/deployment/setup.sh b/deployment/setup.sh
index 23154728..38b484ee 100755
--- a/deployment/setup.sh
+++ b/deployment/setup.sh
@@ -71,6 +71,7 @@ EOF
# Reload systemd and start service
sudo systemctl daemon-reload
sudo systemctl restart transcription
+sudo systemctl disable transcription
sudo systemctl enable transcription
# Check service status
diff --git a/docker-compose.example.yml b/docker-compose.example.yml
index 53848f15..6bc91e3e 100644
--- a/docker-compose.example.yml
+++ b/docker-compose.example.yml
@@ -37,6 +37,7 @@ services:
- TRANSCRIPTION_BASE_URL=http://your_local_api_url:port/v1/
- 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.
# Application settings
- ALLOW_REGISTRATION=false
@@ -59,4 +60,4 @@ services:
# speakr-uploads:
# name: custom-speakr-uploads-name
# speakr-instance:
-# name: custom-speakr-instance-name
\ No newline at end of file
+# name: custom-speakr-instance-name
diff --git a/readme.md b/readme.md
index 66d0be5e..765f53b2 100644
--- a/readme.md
+++ b/readme.md
@@ -95,6 +95,7 @@ The easiest way to deploy Speakr is using Docker and docker compose.
- TRANSCRIPTION_BASE_URL=http://your_local_api_url:port/v1/
- 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.
# Application settings
- ALLOW_REGISTRATION=false
@@ -356,6 +357,7 @@ Configuration is primarily handled through environment variables in the `docker-
* `TRANSCRIPTION_BASE_URL`: **Required.** The base URL for your transcription API endpoint (e.g., `http://localhost:8787/v1/`).
* `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.
* `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`.