From 5892e3a2a1659b3750a2283f47d3caa68fdc1901 Mon Sep 17 00:00:00 2001 From: Chidi Williams Date: Mon, 1 May 2023 10:15:41 +0000 Subject: [PATCH] Add new lines in TXT segments (#436) --- buzz/transcriber.py | 4 +--- tests/transcriber_test.py | 2 +- tests/widgets/transcription_viewer_test.py | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/buzz/transcriber.py b/buzz/transcriber.py index 12e99ae4..74e87234 100644 --- a/buzz/transcriber.py +++ b/buzz/transcriber.py @@ -596,9 +596,7 @@ def write_output(path: str, segments: List[Segment], output_format: OutputFormat if output_format == OutputFormat.TXT: for (i, segment) in enumerate(segments): file.write(segment.text) - if i < len(segments) - 1: - file.write(' ') - file.write('\n') + file.write('\n') elif output_format == OutputFormat.VTT: file.write('WEBVTT\n\n') diff --git a/tests/transcriber_test.py b/tests/transcriber_test.py index 1e7f3f26..2ac02c0b 100644 --- a/tests/transcriber_test.py +++ b/tests/transcriber_test.py @@ -209,7 +209,7 @@ class TestWhisperCpp: @pytest.mark.parametrize( 'output_format,output_text', [ - (OutputFormat.TXT, 'Bien venue dans\n'), + (OutputFormat.TXT, 'Bien\nvenue dans\n'), ( OutputFormat.SRT, '1\n00:00:00,040 --> 00:00:00,299\nBien\n\n2\n00:00:00,299 --> 00:00:00,329\nvenue dans\n\n'), diff --git a/tests/widgets/transcription_viewer_test.py b/tests/widgets/transcription_viewer_test.py index beeba185..278dee7a 100644 --- a/tests/widgets/transcription_viewer_test.py +++ b/tests/widgets/transcription_viewer_test.py @@ -71,4 +71,4 @@ class TestTranscriptionViewerWidget: export_button.menu().actions()[0].trigger() output_file = open(output_file_path, 'r', encoding='utf-8') - assert 'Bien venue dans' in output_file.read() + assert 'Bien\nvenue dans' in output_file.read()