mirror of
https://github.com/chidiwilliams/buzz.git
synced 2026-03-14 14:45:46 +01:00
Will combine sentences into paragraphs when exporting txt (#889)
This commit is contained in:
parent
717f855288
commit
6fa9c8db06
5 changed files with 24 additions and 9 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue