Skip to Content
Web API クックブック
book

Web API クックブック

by Joe Attardi
March 2025
Intermediate to advanced
286 pages
3h 36m
Japanese
O'Reilly Media, Inc.
Content preview from Web API クックブック

第9章. ウェブ音声API

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

はじめに

スマートデバイスとアシスタントの時代において、音声もまた一般的に使われる入力方法となった。テキストメッセージを口述するにしても、明日の天気予報を尋ねるにしても、音声認識と合成はアプリ開発において便利なツールになりつつある。Web Speech APIを使えば、アプリにユーザの音声入力をしゃべらせたり聞かせたりすることができる。

音声認識

Web Speech APIは、ブラウザに音声認識をもたらす。ユーザがマイクの使用許可を与えると、音声を聞き取る。一連の単語を認識すると、認識された内容のイベントがトリガーされる。

音声認識は、まだすべてのブラウザでサポートされていない可能性がある。最新の互換性データについてはCanIUseを参照のこと。

盗聴を開始するには、ユーザの許可が必要である。プライバシーのセットにより、初めて聞き取りを行おうとすると、ユーザはアプリにマイクの使用許可を与えるよう促される(図9-1参照)。

A microphone permission request in Chrome
図9-1. Chromeでのマイク許可リクエスト

Chromeのような一部のブラウザでは、音声認識のために、取り込んだ音声を分析する外部サーバを使用している。つまり、オフラインの状態では音声認識は機能せず、プライバシーの問題も生じる可能性がある。

音声合成

Web Speech APIは音声合成も提供する。テキストが与えられれば、そのテキストを話す合成音声を作成することができる。ブラウザーには、コンテンツを話すのに使える内蔵音声のセットがある。ターゲット言語に適した音声を選択したら、音声のピッチや話す速度をカスタマイズできる。

音声認識と合成を組み合わせて、会話型の音声ユーザ・インタフェースを作成することができる。質問やコマンドを聞き、出力やフィードバックを話すことができる。

ブラウザサポート

本稿執筆時点では、Web Speech APIのサポートはやや限定的である。

このAPIの仕様には、ブラウザでサポートされるようになった音声認識と合成を強化するための、他のいくつかの部品も追加されている。

その第一がカスタム文法で、認識させたい単語やフレーズを指定して音声認識を微調整できる。例えば、音声コマンドで電卓を設計する場合、カスタム文法には数字("1"、"2 "など)や演算子("プラス"、"マイナス "など)が含まれる。カスタム文法を使用することで、音声認識エンジンがアプリケーションが探している単語をキャプチャできるようにガイドすることができる。

SpeechSynthesis ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

RESTful Web API パターンと実践クックブック

RESTful Web API パターンと実践クックブック

Mike Amundsen
実践 Keycloak ―OpenID Connect、OAuth 2.0を利用したモダンアプリケーションのセキュリティー保護

実践 Keycloak ―OpenID Connect、OAuth 2.0を利用したモダンアプリケーションのセキュリティー保護

Stian Thorgersen, Pedro Igor Silva, 和田 広之, 田村 広平, 乗松 隆志, 田畑 義之
JavaScript 第7版

JavaScript 第7版

David Flanagan, 村上 列

Publisher Resources

ISBN: 9798341632431