Add corrections for speaking.

This commit is contained in:
Cristiano Ferreira
2024-01-12 19:45:58 +00:00
parent 5aedd1864d
commit de4042efac
2 changed files with 21 additions and 0 deletions

View File

@@ -251,3 +251,14 @@ def get_misspelled_pairs(text):
# Filter out items with the same value for misspelled and correction
filtered_data = [item for item in response["misspelled_words"] if item['misspelled'] != item['correction']]
return filtered_data
def get_speaking_corrections(text):
message = ('Given the provided transcription, identify and extract any inaccuracies, including incorrect words and '
'expressions. Put them in the json with the correct words and expressions that should be on the transcription '
'instead. Sample JSON: {"corrections":[{"wrong": "wrong_word", "correct": "correct_word"}] '
'\n The text: "' + text + '"')
token_count = count_tokens(message)["n_tokens"]
response = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, message, token_count, ["corrections"], 0.2)
# Filter out items with the same value for misspelled and correction
filtered_data = [item for item in response["corrections"] if item['wrong'] != item['correct']]
return filtered_data