diff options
-rwxr-xr-x | bulk-audio/get | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bulk-audio/get b/bulk-audio/get index 5a0b3c4..196a5d5 100755 --- a/bulk-audio/get +++ b/bulk-audio/get @@ -9,9 +9,13 @@ urlencode() { printf '%s' "$1" | od -An -tx1 | tr ' ' '%' | tr '[:lower:]' '[:upper:]' } +normalize_kana() { + sed 'y/テデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅ/てでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんゔぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづ/' +} + local_audio() { URL="http://localhost:5050/" - res="$(curl -sLGo - "$URL" --data-urlencode "term=$KANJI" --data-urlencode "reading=$KANA")" + res="$(curl -sLGo - "$URL" --data-urlencode "term=$KANJI" --data-urlencode "reading=$(echo "$KANA" | normalize_kana)")" [ $? -ne 0 ] && return URL="$(echo "$res" | jq --raw-output '.audioSources[0].url // empty')" [ -z "$URL" ] && return |