"人工知能 API" Microsoft Azure Cognitive Services を使うと、音声⇔テキスト変換や翻訳 を行うエンジンをノーコーディングで利用、作成できます。
- Speech-to-Text : 標準およびカスタム音声や会話の文字起こし
- Text-to-Speech : 標準およびカスタムのテキスト読み上げ
- Speech Translation : 音声翻訳
- Speech-to-Text (C#(UWP) | HTML/JavaScript)
- Text-to-Speech (C#(Console | UWP) | Node.js)
Speech Service のサブスクリプション申込を行い、ロケーション(場所、Region)と API キー (Key1) を取得しておきます。
MainPage.xaml.cs にある、YOUR_API_KEY と YOUR_LOCATION にご自分のサブスクリプションの情報(APIキー、サービスを作成したロケーション(westus, japaneast など))を入力します。
private async Task SpeechRecognizeAsync()
{
var config = SpeechConfig.FromSubscription("YOUR_API_KEY", "YOUR_LOCATION");
index.html を起動し、表示される Subscription Key と Region の欄にご自分のサブスクリプションの情報(APIキー、サービスを作成したロケーション(westus, japaneast など))を入力します。
Program.cs にある、YOUR_API_KEY と YOUR_LOCATION にご自分のサブスクリプションの情報(APIキー、サービスを作成したロケーション(westus, japaneast など))を入力します。
public static async Task SynthesisToSpeakerAsync()
{
var config = SpeechConfig.FromSubscription("YOUR_API_KEY", "YOUR_LOCATION");
MainPage.xaml.cs にある、YOUR_API_KEY と YOUR_LOCATION にご自分のサブスクリプションの情報(APIキー、サービスを作成したロケーション(westus, japaneast など))を入力します。
private async void SpeakButton_Clicked(object sender, RoutedEventArgs e)
{
var config = SpeechConfig.FromSubscription("YOUR_API_KEY", "YOUR_LOCATION");
TTS.js にある YOUR_API_KEY と YOUR_LOCATION にご自分のサブスクリプションの情報(APIキー、サービスを作成したロケーション(westus, japaneast など))を入力します。
const location = "YOUR_LOCATION";
const apiKey = "YOUR_API_KEY";
出力したい言語を変更するには function textToSpeech の以下の箇所をを以下のように変更します;
function textToSpeech(accessToken, text) {
// Create the SSML request.
let xml_body = xmlbuilder.create('speak')
.att('version', '1.0')
.att('xml:lang', 'en-us')
.ele('voice')
.att('xml:lang', 'en-us')
.att('name', 'Microsoft Server Speech Text to Speech Voice (en-US, Guy24KRUS)')
- 英語(初期設定): Microsoft Server Speech Text to Speech Voice (en-US, Guy24KRUS)
- 日本語: Microsoft Server Speech Text to Speech Voice (ja-JP, HarukaRUS)
対応言語については、Speech Service のドキュメント をご確認ください。