from difflib import SequenceMatcher ''' 1. two array, 1.Ground truth 2.from pytrancriber 2. get 1st index from both, if Ground Truth one is too short, get 2 or 3 even more 3. compare by mp3 len???? ''' def similar(a, b): return SequenceMatcher(None, a, b).ratio() def gen_mp3_from_text(gt,gen): tts=gTTS(text=gen, lang='zh') tts.save("gen_tmp.mp3") tts=gTTS(text=gt, lang='zh') tts.save("gt_tmp.mp3") audio = MP3("gen_tmp.mp3") gen_len = audio.info.length audio = MP3("gt_tmp.mp3") gt_len = audio.info.length return gt_len, gen_len def adjustSub(gt_array, generated_array): for gen_idx in return adjusted_array from gtts import gTTS tts=gTTS(text='玉米燕麥豆是一位居住在英國倫敦的日益女性', lang='zh') tts.save("1.mp3") tts=gTTS(text='yumi yamato是一位居住在英國倫敦的日益女性', lang='zh') tts.save("2.mp3") from mutagen.mp3 import MP3 audio = MP3("1.mp3") print(audio.info.length) audio = MP3("2.mp3") print(audio.info.length)