1 Answer
- Newest
- Most votes
- Most comments
0
hi,
At the moment, there is no api parameter to disable the number Transcribe feature(https://docs.aws.amazon.com/transcribe/latest/dg/how-numbers.html). but there are some post process step you can apply, for example, you can use
- num2word library (https://pypi.org/project/num2words/)
from num2words import num2words
# Define a function to convert numbers in a sentence to words
def convert_numbers_to_words(sentence):
words = []
for word in sentence.split():
# Check if the word is a number
if word.isnumeric():
# Convert the number to words and append to the list
words.append(num2words(word))
else:
# Append the original word to the list
words.append(word)
# Join the words back into a sentence
return " ".join(words)
# Example usage
sentence = "I just spent 50 dollars"
converted_sentence = convert_numbers_to_words(sentence)
print(converted_sentence)
- inflect library (https://pypi.org/project/inflect/)
import inflect
import re
def convert_numbers_to_words(text):
p = inflect.engine()
words = text.split()
new_words = []
for word in words:
if word.isdigit():
word = p.number_to_words(word)
new_words.append(word)
return ' '.join(new_words)
transcribed_text = "I just spent 50 dollars"
converted_text = convert_numbers_to_words(transcribed_text)
print(converted_text)
- or just your simple dictionary - {number: word} with re and replacement
hope that helps you.
answered 2 years ago
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 10 days ago