Python Script Not Generating Sync Map Despite Successful Command Line Execution

25 views Asked by At

I'm using aeneas to synchronize text with audio. When I execute the task through the command line, it works perfectly and generates a synchronization map as expected. However, when I try to replicate the same process within a Python script, the script executes without errors, but the resulting synchronization map file is empty.

Here's the command line execution that works successfully:

python -m aeneas.tools.execute_task "path\to\audio.mp3" "path\to\textfile.txt" "task_language=eng|is_text_type=plain|os_task_file_format=srt" "path\to\output\syncmap.srt"

And here's the equivalent portion of my Python script:

from aeneas.executetask import ExecuteTask
from aeneas.task import Task
import os

def align_text_with_audio_simple(text_file_path, audio_file_path, output_syncmap_path):
    config_string = "task_language=eng|is_text_type=plain|os_task_file_format=srt"
    task = Task(config_string=config_string)
    task.text_file_path_absolute = text_file_path
    task.audio_file_path_absolute = audio_file_path
    task.sync_map_file_path_absolute = output_syncmap_path

    try:
        ExecuteTask(task).execute()
        print(f"Alignment saved to {output_syncmap_path}")
    except Exception as e:
        print(f"Error during alignment: {e}")

text_file_path = "path\\to\\textfile.txt"
audio_file_path = "path\\to\\audio.mp3"
output_syncmap_path = "path\\to\\output\\syncmap.srt"

align_text_with_audio_simple(text_file_path, audio_file_path, output_syncmap_path)

Diagnostic checks with python -m aeneas.diagnostics indicate that all required dependencies are met, but note that Python C extensions like aeneas.cdtw, aeneas.cmfcc, and aeneas.cew are not available, which should only affect performance, not functionality.

The script runs without throwing any exceptions, the aeneas task appears to execute, but the syncmap.srt file remains empty. I've verified that the audio and text closely match and that the paths and filenames are correct. The environment is consistent between the command line and script executions.

0

There are 0 answers