darker model name text
This commit is contained in:
@ -43,16 +43,19 @@ pub fn transcribe_audio(
|
|||||||
args.push(lang);
|
args.push(lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run Python script
|
// Run Python script with timeout
|
||||||
let output = Command::new(python_exe)
|
let output = Command::new(python_exe)
|
||||||
.args(&args)
|
.args(&args)
|
||||||
.env("PYTHONPATH", crate::paths::project_root().join(".venv312").join("lib").join("python3.12").join("site-packages"))
|
.env("PYTHONPATH", crate::paths::project_root().join(".venv312").join("lib").join("python3.12").join("site-packages"))
|
||||||
.output()
|
.output()
|
||||||
.map_err(|e| format!("Failed to run Python script: {}", e))?;
|
.map_err(|e| format!("Failed to run Python script: {}", e))?;
|
||||||
|
|
||||||
|
// Check for timeout or other errors
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||||
return Err(format!("Python script failed: {}", stderr));
|
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||||
|
return Err(format!("Python script failed: {}\nStdout: {}\nStderr: {}",
|
||||||
|
output.status, stdout, stderr));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse JSON output
|
// Parse JSON output
|
||||||
|
|||||||
@ -21,6 +21,13 @@ def main():
|
|||||||
model_name = sys.argv[2]
|
model_name = sys.argv[2]
|
||||||
language = sys.argv[3] if len(sys.argv) > 3 else None
|
language = sys.argv[3] if len(sys.argv) > 3 else None
|
||||||
|
|
||||||
|
# Check file size - warn for very large files
|
||||||
|
import os
|
||||||
|
file_size_mb = os.path.getsize(audio_file) / (1024 * 1024)
|
||||||
|
if file_size_mb > 100: # Warn for files over 100MB
|
||||||
|
print(f"Warning: Large file detected ({file_size_mb:.1f}MB). Transcription may take a long time.", file=sys.stderr)
|
||||||
|
print("Consider splitting long audio files into smaller segments for faster processing.", file=sys.stderr)
|
||||||
|
|
||||||
# Extract audio to temp WAV if needed
|
# Extract audio to temp WAV if needed
|
||||||
with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as tmp:
|
with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as tmp:
|
||||||
wav_path = tmp.name
|
wav_path = tmp.name
|
||||||
@ -40,7 +47,9 @@ def main():
|
|||||||
|
|
||||||
model = WhisperModel(model_name, device=device, compute_type=compute_type)
|
model = WhisperModel(model_name, device=device, compute_type=compute_type)
|
||||||
|
|
||||||
# Transcribe
|
# Transcribe with progress reporting
|
||||||
|
print(f"Starting transcription of {wav_path} with model {model_name}", file=sys.stderr)
|
||||||
|
|
||||||
segments, info = model.transcribe(
|
segments, info = model.transcribe(
|
||||||
wav_path,
|
wav_path,
|
||||||
language=language,
|
language=language,
|
||||||
@ -50,6 +59,8 @@ def main():
|
|||||||
vad_parameters=dict(threshold=0.5, min_speech_duration_ms=250),
|
vad_parameters=dict(threshold=0.5, min_speech_duration_ms=250),
|
||||||
without_timestamps=False
|
without_timestamps=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print(f"Transcription completed. Detected language: {info.language}", file=sys.stderr)
|
||||||
|
|
||||||
# Convert to our format
|
# Convert to our format
|
||||||
words = []
|
words = []
|
||||||
|
|||||||
Reference in New Issue
Block a user