voice-matcher-api / app /matcher.py
arnabg95's picture
v2 added
cc08b68
raw
history blame contribute delete
No virus
639 Bytes
import difflib
from fuzzywuzzy import fuzz
# Custom phonetic matching function
def phonetic_match(word1, word2):
"""
Compares two words based on their phonetic similarity.
"""
return fuzz.ratio(word1, word2) / 100
# Custom sequence matching function
def sequence_match(a, b):
"""
Uses sequence matching to compare two sequences of words.
"""
return difflib.SequenceMatcher(None, a, b).ratio()
def match(original, transcription):
sequence = sequence_match(original.lower(), transcription.lower())
phonetic = phonetic_match(original.lower(), transcription.lower())
return sequence, phonetic