Skip to content

Commit

Permalink
[style] Remove whitespaces (W291, W293)
Browse files Browse the repository at this point in the history
  • Loading branch information
ftnext committed Apr 2, 2024
1 parent 9852fa4 commit b196ea1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions speech_recognition/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ def recognize_amazon(self, audio_data, bucket_name=None, access_key_id=None, sec
aws_secret_access_key=secret_access_key,
region_name=region)

s3 = boto3.client('s3',
s3 = boto3.client('s3',
aws_access_key_id=access_key_id,
aws_secret_access_key=secret_access_key,
region_name=region)
Expand Down Expand Up @@ -1137,7 +1137,7 @@ def recognize_amazon(self, audio_data, bucket_name=None, access_key_id=None, sec
else:
# Some other error happened, so re-raise.
raise

job = status['TranscriptionJob']
if job['TranscriptionJobStatus'] in ['COMPLETED'] and 'TranscriptFileUri' in job['Transcript']:

Expand Down Expand Up @@ -1167,7 +1167,7 @@ def recognize_amazon(self, audio_data, bucket_name=None, access_key_id=None, sec

return transcript, confidence
elif job['TranscriptionJobStatus'] in ['FAILED']:

# Delete job.
try:
transcribe.delete_transcription_job(TranscriptionJobName=job_name) # cleanup
Expand All @@ -1177,7 +1177,7 @@ def recognize_amazon(self, audio_data, bucket_name=None, access_key_id=None, sec

# Delete S3 file.
s3.delete_object(Bucket=bucket_name, Key=filename)

exc = TranscriptionFailed()
exc.job_name = None
exc.file_key = None
Expand Down Expand Up @@ -1436,23 +1436,23 @@ def recognize_whisper(self, audio_data, model="base", show_dict=False, load_opti
return result
else:
return result["text"]

def recognize_vosk(self, audio_data, language='en'):
from vosk import KaldiRecognizer, Model

assert isinstance(audio_data, AudioData), "Data must be audio data"

if not hasattr(self, 'vosk_model'):
if not os.path.exists("model"):
return "Please download the model from https://github.com/alphacep/vosk-api/blob/master/doc/models.md and unpack as 'model' in the current folder."
exit (1)
self.vosk_model = Model("model")

rec = KaldiRecognizer(self.vosk_model, 16000);

rec.AcceptWaveform(audio_data.get_raw_data(convert_rate=16000, convert_width=2));
finalRecognition = rec.FinalResult()

return finalRecognition


Expand Down

0 comments on commit b196ea1

Please sign in to comment.