Skip to content

Commit

Permalink
Fix for extra spaces in whisper.cpp transcripts (#890)
Browse files Browse the repository at this point in the history
  • Loading branch information
raivisdejus committed Aug 17, 2024
1 parent 6fa9c8d commit 12c1ac8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions buzz/transcriber/file_transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def run(self):
self.error.emit(str(exc))
return

for segment in segments:
segment.text = segment.text.strip()

self.completed.emit(segments)

for (
Expand Down
6 changes: 3 additions & 3 deletions tests/transcriber/whisper_cpp_file_transcriber_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TestWhisperCppFileTranscriber:
False,
[Segment(0, 6560, "Bienvenue dans Passe-Relle. Un podcast pensé pour")],
),
(True, [Segment(30, 740, "Bienvenue"), Segment(740, 1070, " dans")]),
(True, [Segment(30, 740, "Bienvenue"), Segment(740, 1070, "dans")]),
],
)
def test_transcribe(
Expand Down Expand Up @@ -81,9 +81,9 @@ def test_transcribe(
[
(
False,
[Segment(0, 7000, " Mani uzstrauts, laikabstākļi, tapēc uz jūru, es diezvajī braukša.")],
[Segment(0, 7000, "Mani uzstrauts, laikabstākļi, tapēc uz jūru, es diezvajī braukša.")],
),
(True, [Segment(380, 500, " Mani"), Segment(500, 1880, " uzstrauts,"), Segment(1880, 3920, " laikabstākļi")]),
(True, [Segment(380, 500, "Mani"), Segment(500, 1880, "uzstrauts,"), Segment(1880, 3920, "laikabstākļi")]),
],
)
# Problematic part is in "laikabstākļi" where "ļ" gets returned from whisper.cpp in two segments
Expand Down

0 comments on commit 12c1ac8

Please sign in to comment.