文字起こしサービスAmazon Transcribeがカスタム語彙に対応しました

2018.04.05

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

AWS Summits 2018 San Francisco で文字起こしサービスAmazon Transcribeが正式リリースされました。 正式リリースに伴い追加された機能の一つがカスタム語彙です。

AWSの製品ページからカスタム語彙のメリットを引用します。

Amazon Transcribe では音声認識語彙の拡張とカスタマイズを行うことができます。特殊な用語や専門用語、固有の製品名が発話に含まれている場合でも、ベース語彙に新規単語 (発音も含む) を追加することで、特定のユースケースに合った高精度な文字起こしテキストを生成できます。

やってみた

本ブログでは管理コンソールからカスタム語彙を登録して文字起こしする手順を解説します。

文字起こし対象には re:Invent 2017 での Andy Jassy の AWS Fargate 発表を利用します。

専門用語が連呼される、ドメイン度高めの音声です。

カスタム語彙を定義することで、文字起こし精度を高められるのでしょうか。

カスタム語彙の無し/有りで文字起こし後のテキストを比較したいと思います。

事前準備

Amazon Transcribe を利用するにあたり、S3 バケットの作成や S3 バケットのポリシー設定が必要です。 次の記事を参考にして下さい。

AWS CLIからAmazon Transcribeを使って文字起こししてみた

まずは Amazon Transcribe の管理画面に移動します。

現時点で以下のリージョンでサービスが提供されています。

  • US East (N. Virginia)
  • US East (Ohio)
  • US West (Oregon)
  • EU (Ireland)

今回は US East リージョンを利用します。

カスタム語彙を利用せずに文字起こし

以下の transcript が得られました。

So we're really excited about chaos, and now you've got to manage containers that you can choose from chaos and people are excited about that, but what we've heard from customers has managed containers makes our life much, much easier. Thank you very much. However there's always a, however, it would be great if we could run containers without having to worry about servers or clusters of these things. We thought. Ok, well, we thought manage containers were pretty good, but that's interesting running containers without managing service. So we thought about that as a team is a tricky problem we worked on after the last year. I'm excited to announce new capability called a ws far gate, which allows you to run containers without having to manage servers or clusters. So far, gate is really simple to use you just packed your application to tasks which people are used to doing nothing to manage this, that the task level it's best to cebu in the memory you need, you find the network and the identity access management that you're going to need, and then you upload everything afar gate and far gate to place those task for you, and then automatically scales it out across multiple availability zones and auto scale for you there's no servers, no clusters. No provisioning. It sets up all the surrounding infrastructure. Need to be able to run this thing really hands off the wheel. It totally changes the way that you could run containers. People want to run containers of the task level of the cannon said of the server level, and far get radically changes. How you can now run containers very excited about this.

専門用語が使われ、うまく文字起こしできなかった箇所を幾つかピックアップします。

  • "So we're really excited about EKS"では"EKS" が "chaos" となっています。
  • "you can choose from EC2 and EKS" も "you can choose from chaos" となっていて、"EKS" が "chaos" になっているだけでなく、EC2 がごっそり欠落しています。
  • サービス名の ”Fargate" が "far gate" となっています。(一般的な辞書に "fargate" の単語は存在しません。)
  • "called AWS Fargate" が "called a ws far gate" となっています。そもそも transcript に AWS の文字が一つも存在していませんね。
  • "it specifies the CPU and the memory" が "it's best to cebu in the memory" となっています。CPU が cebu になっています。

登録するカスタム語彙

音声と transcript の比較から、以下の語彙を登録してみることにしました。

  • EC2
  • EKS
  • AWS
  • Fargate
  • CPU

カスタム語彙の制約

カスタム語彙には以下の制約があります。

  • 英語またはスペイン語
  • 各語彙は 256 文字以下
  • 語彙全体で 50 KB 以下
  • 決められた文字で構成されている。英語の場合は、大文字・小文字のアルファベットとハイフンのみ

4つ目が曲者です。

スペースは登録出来ないため、"IP Address"のように複数語で構成される語彙は "IP-Address" のようにハイフンで結合します。

また、"EC2"のように数字("2")は語彙として登録出来ません。

この制限に気づかずに登録しようとしたところ "The vocabulary that you’re trying to create contains invalid characters. See the developer guide for more information." というエラーが発生しました。

仕方なしに今回は "EC2""EC-Two"で登録しました。

カスタム語彙の登録方法

語彙ファイルの作成

API や管理画面からCSVファイルアップロードで登録可能です。

今回は、管理画面から語彙をアップロードすることにし、次のファイルを用意しました。

aws.txt

EC-two
EKS
AWS
fargate
CPU

詳細は各マニュアルを参照下さい。

語彙のアップロード

管理画面の「Custom vocabulary」に移動し、このファイルに名前をつけて(今回は"aws"としました)、英語語彙としてアップロードします。

ステータスが「Pending」から「Ready」に変われば、語彙の登録は完了したことになります。

カスタム語彙を利用して文字起こし

今後は作成したカスタム語彙を利用して文字起こしします。

ジョブ作成画面をよく確認すると、プレビュー時代にはなかった「Apply custom vocabulary」を利用します。

説明文には"A custom vocabulary improves the accuracy of recognizing words, phrases, and commands."とあります。期待できそうです。

プルダウンから作成した語彙を選択し、ジョブを開始します。

以下の transcript が得られました。

So we're really excited about EKS and now you've got to manage containers that you can choose from chaos and people are excited about that but what we've heard from customers has managed containers makes our life much much easier thank you very much however there's always a however it would be great if we could run containers without having to worry about servers or clusters of these things we thought ok well we thought manage containers were pretty good but that's interesting running containers without managing service so we thought about that as a team is a tricky problem we worked on after the last year i'm excited to announce new capability called eight of us fargate which allows you to run containers without having to manage servers or clusters AWS so fargate is really simple to use you just packed your application to tasks which people are used to doing nothing to manage this that the task level it's best to CPU in the memory you need you find the network and the identity access management that you're going to need and then you upload everything fargate and fargate to place those task for you and then automatically scales it out across multiple availability zones and auto scale for you there's no servers no clusters no provisioning it sets up all the surrounding infrastructure need to be able to run this thing really hands off the wheel it totally changes the way that you could run containers people want to run containers of the task level of the, cannon said of the server level. And fargate radically changes how you can now run containers very excited about this.

カスタム語彙の効果を確認する

transcript 全体の比較は一旦保留し、カスタム語彙を登録する原因となった箇所を確認します。

EKS/EC2

語彙無しでは "So we're really excited about chaos, and now you've got to manage containers that you can choose from chaos" と書き起こされていましたが、語彙登録により前半部分は "So we're really excited about EKS" と正しく書き起こされるようになりました。

ただし、後半部分の ”you can choose from EC2 and EKS" は相変わらず "you can choose from chaos" となっています。

fargate

バニラ状態では "far gate" と書き起こされていましたが、語彙の登録により正しく "fargate" と書き起こされています。

この語彙登録では一番効果がありました。

AWS

"called AWS Fargate" がバニラ状態で "called a ws far gate" となっていた問題は、 "called eight of us fargate" というように AWS 部分が何故か "eight of us" になっています。

CPU

"it specifies the CPU and the memory" が "it's best to cebu in the memory" となっていた問題は、"it's best to CPU in the memory" となっています。語彙 CPU を認識出来るようになりました。

AWS CLI/AWS SDK for Python (Boto)からのカスタム語彙の操作

AWS CLI からのカスタム語彙の操作は次のブログを参照して下さい。

AWS CLIからAmazon Transcribeのカスタム語彙を触ってみた

AWS SDK for Python (Boto)からのカスタム語彙の操作は次のブログを参照して下さい。

AWS SDK for Python (Boto)からAmazon Transcribeのカスタム語彙を触ってみた

まとめ

Amazon Transcribe の新機能、カスタム語彙を試してみました。

文字起こしやカスタム語彙の癖などノウハウが貯まると、精度の向上に力を発揮しそうです。

参考