diff --git a/buzz/transcriber/file_transcriber.py b/buzz/transcriber/file_transcriber.py index ed7f9505..ef0f4ec2 100644 --- a/buzz/transcriber/file_transcriber.py +++ b/buzz/transcriber/file_transcriber.py @@ -118,9 +118,16 @@ def write_output( with open(path, "w", encoding="utf-8") as file: if output_format == OutputFormat.TXT: - for i, segment in enumerate(segments): - file.write(getattr(segment, segment_key)) - file.write("\n") + combined_text = "" + previous_end_time = None + + for segment in segments: + if previous_end_time is not None and (segment.start - previous_end_time) >= 2000: + combined_text += "\n\n" + combined_text += getattr(segment, segment_key).strip() + " " + previous_end_time = segment.end + + file.write(combined_text) elif output_format == OutputFormat.VTT: file.write("WEBVTT\n\n") diff --git a/buzz/widgets/transcription_viewer/transcription_viewer_widget.py b/buzz/widgets/transcription_viewer/transcription_viewer_widget.py index 8edf8a04..b0ec6714 100644 --- a/buzz/widgets/transcription_viewer/transcription_viewer_widget.py +++ b/buzz/widgets/transcription_viewer/transcription_viewer_widget.py @@ -206,9 +206,17 @@ class TranscriptionViewerWidget(QWidget): segments = self.transcription_service.get_transcription_segments( transcription_id=self.transcription.id_as_uuid ) - self.text_display_box.setPlainText( - " ".join(segment.text.strip() for segment in segments) - ) + + combined_text = "" + previous_end_time = None + + for segment in segments: + if previous_end_time is not None and (segment.start_time - previous_end_time) >= 2000: + combined_text += "\n\n" + combined_text += segment.text.strip() + " " + previous_end_time = segment.end_time + + self.text_display_box.setPlainText(combined_text.strip()) self.text_display_box.show() self.table_widget.hide() else: # ViewMode.TRANSLATION diff --git a/docs/docs/usage/translations.md b/docs/docs/usage/translations.md index 5d3d3f3c..23924f29 100644 --- a/docs/docs/usage/translations.md +++ b/docs/docs/usage/translations.md @@ -4,7 +4,7 @@ title: Translations Default `Translation` task uses Whisper model ability to translate to English. Since version `1.0.0` Buzz supports additional AI translations to any other language. -To use translation feature you will need to configure OpenAI API key and translation settings. Set OpenAI API ket in Preferences. Buzz also supports custom locally running translation AIs that support OpenAI API. For more information on locally running AIs see [ollama](https://ollama.com/blog/openai-compatibility) or [LM Studio](https://lmstudio.ai/). +To use translation feature you will need to configure OpenAI API key and translation settings. Set OpenAI API ket in Preferences. Buzz also supports custom locally running translation AIs that support OpenAI API. For more information on locally running AIs see [ollama](https://ollama.com/blog/openai-compatibility) or [LM Studio](https://lmstudio.ai/). For information on available custom APIs see this [discussion thread](https://github.com/chidiwilliams/buzz/discussions/827) To configure translation for Live recordings enable it in Advances settings dialog of the Live Recording settings. Enter AI model to use and prompt with instructions for the AI on how to translate. Translation option is also available for files that already have speech recognised. Use Translate button on transcription viewer toolbar. diff --git a/tests/transcriber/transcriber_test.py b/tests/transcriber/transcriber_test.py index f3df832c..0a6dd80c 100644 --- a/tests/transcriber/transcriber_test.py +++ b/tests/transcriber/transcriber_test.py @@ -18,7 +18,7 @@ class TestToTimestamp: @pytest.mark.parametrize( "output_format,output_text", [ - (OutputFormat.TXT, "Bien\nvenue dans\n"), + (OutputFormat.TXT, "Bien venue dans "), ( 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/export_transcription_menu_test.py b/tests/widgets/export_transcription_menu_test.py index 819ea054..e326b809 100644 --- a/tests/widgets/export_transcription_menu_test.py +++ b/tests/widgets/export_transcription_menu_test.py @@ -61,4 +61,4 @@ class TestExportTranscriptionMenu: widget.actions()[0].trigger() with open(output_file_path, encoding="utf-8") as output_file: - assert "Bien\nvenue dans" in output_file.read() + assert "Bien venue dans" in output_file.read()