-
Notifications
You must be signed in to change notification settings - Fork 1
Sourcery refactored master branch #2
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,10 +25,14 @@ def __try_detect_language(self, target_language): | |
return self.__DEFAULT_VOICE | ||
|
||
all_voices = self.list_voices() | ||
for voice in all_voices['voices']: | ||
if target_language in voice['language']: | ||
return voice['name'] | ||
return self.__DEFAULT_VOICE | ||
return next( | ||
( | ||
voice['name'] | ||
for voice in all_voices['voices'] | ||
if target_language in voice['language'] | ||
), | ||
self.__DEFAULT_VOICE, | ||
) | ||
Comment on lines
-28
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
def speech(self, text, file_name=__NOT_DEFINED, | ||
voice=__NOT_DEFINED, language=__NOT_DEFINED, play_after=True): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,14 @@ def list_languages(self): | |
|
||
def search_language_code(self, language_name): | ||
all_languages = self.list_languages() | ||
for language in all_languages['languages']: | ||
if language['language_name'].lower() == language_name.lower(): | ||
return language['language'] | ||
return None | ||
return next( | ||
( | ||
language['language'] | ||
for language in all_languages['languages'] | ||
if language['language_name'].lower() == language_name.lower() | ||
), | ||
None, | ||
) | ||
Comment on lines
-24
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
def translate(self, text, source, target): | ||
self.__validate() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
SpeechToText.read
refactored with the following changes:de-morgan
)