Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will combine sentences into paragraphs when exporting txt #889

Merged
merged 2 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions buzz/transcriber/file_transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,16 @@

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"

Check warning on line 126 in buzz/transcriber/file_transcriber.py

View check run for this annotation

Codecov / codecov/patch

buzz/transcriber/file_transcriber.py#L126

Added line #L126 was not covered by tests
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")
Expand Down
14 changes: 11 additions & 3 deletions buzz/widgets/transcription_viewer/transcription_viewer_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,17 @@
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"

Check warning on line 215 in buzz/widgets/transcription_viewer/transcription_viewer_widget.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/transcription_viewer/transcription_viewer_widget.py#L215

Added line #L215 was not covered by tests
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
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/usage/translations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion tests/transcriber/transcriber_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_to_timestamp(self):
@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",
Expand Down
2 changes: 1 addition & 1 deletion tests/widgets/export_transcription_menu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ def test_should_export_segments(
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()
Loading