Skip to content

Instantly share code, notes, and snippets.

@ftnext
Created February 11, 2023 08:18
Show Gist options
  • Save ftnext/c60a32087a25146674edc6eb70bc8fb0 to your computer and use it in GitHub Desktop.
Save ftnext/c60a32087a25146674edc6eb70bc8fb0 to your computer and use it in GitHub Desktop.
シオン・プロジェクトのスパイクとして作ったスクリプト(ESPnetでASRできるか検証)
import argparse
import soundfile
from espnet2.bin.asr_inference import Speech2Text
parser = argparse.ArgumentParser()
parser.add_argument("audio_file_path") # sayコマンドなどで準備する
args = parser.parse_args()
speech2text = Speech2Text.from_pretrained("kan-bayashi/csj_asr_train_asr_transformer_raw_char_sp_valid.acc.ave")
speech_array, sampling_rate = soundfile.read(args.audio_file_path)
nbests = speech2text(speech_array)
text, tokens, *_ = nbests[0]
print(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment