Skip to content

Commit

Permalink
Merge pull request #810 from ftnext/bugfix/recognize-google-cloud-tra…
Browse files Browse the repository at this point in the history
…iling-space

bugfix(google-cloud-speech): Remove trailing space
  • Loading branch information
ftnext authored Dec 22, 2024
2 parents b04353b + ac03f3f commit 9361057
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions speech_recognition/recognizers/google_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def recognize(
if len(response.results) == 0:
raise UnknownValueError()

transcript = ""
for result in response.results:
transcript += result.alternatives[0].transcript.strip() + " "
transcript = " ".join(
result.alternatives[0].transcript.strip()
for result in response.results
)
return transcript
2 changes: 1 addition & 1 deletion tests/recognizers/test_google_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_transcribe_with_google_cloud_speech(SpeechClient, monkeypatch):

actual = recognize(MagicMock(spec=Recognizer), audio_data)

assert actual == "how old is the Brooklyn Bridge "
assert actual == "how old is the Brooklyn Bridge"
SpeechClient.assert_called_once_with()
client.recognize.assert_called_once_with(
config=RecognitionConfig(
Expand Down

0 comments on commit 9361057

Please sign in to comment.