Spaces:
Running
Running
alessandro trinca tornidor
commited on
Commit
·
bafb40b
1
Parent(s):
6e31dbd
feat: prepare a separate function to get a rendom phrase from the phrase dataset
Browse files
aip_trainer/lambdas/lambdaGetSample.py
CHANGED
@@ -63,10 +63,7 @@ def lambda_handler(event, context):
|
|
63 |
try:
|
64 |
current_transcript = str(body["transcript"])
|
65 |
except KeyError:
|
66 |
-
|
67 |
-
current_transcript = lambda_df_lang.get_random_sample_from_df(language, category)
|
68 |
-
app_logger.info(f"category={category}, language={language}, current_transcript={current_transcript}.")
|
69 |
-
# sentence_category = getSentenceCategory(current_transcript[0])
|
70 |
current_transcript = current_transcript if isinstance(current_transcript, str) else current_transcript[0]
|
71 |
current_ipa = lambda_ipa_converter[language].convertToPhonem(current_transcript)
|
72 |
|
@@ -80,6 +77,13 @@ def lambda_handler(event, context):
|
|
80 |
return json.dumps(result)
|
81 |
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
def getSentenceCategory(sentence) -> int:
|
84 |
number_of_words = len(sentence.split())
|
85 |
categories_word_limits = [0, 8, 20, 100000]
|
|
|
63 |
try:
|
64 |
current_transcript = str(body["transcript"])
|
65 |
except KeyError:
|
66 |
+
current_transcript = get_random_selection(language, category, is_gradio_output=False)
|
|
|
|
|
|
|
67 |
current_transcript = current_transcript if isinstance(current_transcript, str) else current_transcript[0]
|
68 |
current_ipa = lambda_ipa_converter[language].convertToPhonem(current_transcript)
|
69 |
|
|
|
77 |
return json.dumps(result)
|
78 |
|
79 |
|
80 |
+
def get_random_selection(language: str, category: int, is_gradio_output=True):
|
81 |
+
lambda_df_lang = lambda_database[language]
|
82 |
+
current_transcript = lambda_df_lang.get_random_sample_from_df(language, category)
|
83 |
+
app_logger.info(f"category={category}, language={language}, current_transcript={current_transcript}.")
|
84 |
+
return current_transcript[0] if is_gradio_output else current_transcript
|
85 |
+
|
86 |
+
|
87 |
def getSentenceCategory(sentence) -> int:
|
88 |
number_of_words = len(sentence.split())
|
89 |
categories_word_limits = [0, 8, 20, 100000]
|