SpeechRecognizer class
從麥克風、檔案或其他音訊輸入資料流程執行語音辨識,並取得轉譯文字的結果。
- Extends
建構函式
Speech |
SpeechRecognizer 建構函式。 |
屬性
authorization |
取得用來與服務通訊的授權權杖。 |
canceled | 事件已取消,表示辨識期間發生錯誤。 |
endpoint |
取得用於語音辨識之自訂語音模型的端點識別碼。 |
internal |
|
output |
取得辨識的輸出格式。 |
properties | 為這個 SpeechRecognizer 定義的屬性及其值集合。 |
recognized | 事件可辨識的訊號表示收到最終辨識結果。 |
recognizing | 事件辨識訊號表示收到中繼辨識結果。 |
speech |
取得辨識的口語語言。 |
telemetry |
此方法會傳回遙測設定的目前狀態。 |
繼承的屬性
session |
定義會話已啟動事件的事件處理常式。 |
session |
定義會話已停止事件的事件處理常式。 |
speech |
定義語音停止事件的事件處理常式。 |
speech |
定義語音啟動事件的事件處理常式。 |
方法
close(() => void, (error: string) => void) | 關閉這個類別實例所持有的所有外部資源。 |
dispose(boolean) | 處置 物件所持有的任何資源。 |
From |
SpeechRecognizer 建構函式。 |
recognize |
啟動語音辨識,並在辨識第一個語句之後停止。 此工作會傳回辨識文字作為結果。 注意:RecognizeOnceAsync () 會在辨識第一個語句時傳回,因此它只適用于單次辨識,例如命令或查詢。 針對長時間執行的辨識,請改用 StartContinuousRecognitionAsync () 。 |
start |
啟動語音辨識,直到呼叫 stopContinuousRecognitionAsync () 為止。 使用者必須訂閱事件,才能接收辨識結果。 |
start |
使用關鍵字點啟動語音辨識,直到呼叫 stopKeywordRecognitionAsync () 為止。 使用者必須訂閱事件,才能接收辨識結果。 注意:關鍵字辨識功能僅適用于語音裝置 SDK。 SDK 本身目前不包含這項功能。 |
stop |
停止連續語音辨識。 |
stop |
停止連續語音辨識。 注意:關鍵字辨識功能僅適用于語音裝置 SDK。 SDK 本身目前不包含這項功能。 |
繼承的方法
enable |
這個方法會全域啟用或停用遙測。 |
建構函式詳細資料
SpeechRecognizer(SpeechConfig, AudioConfig)
SpeechRecognizer 建構函式。
new SpeechRecognizer(speechConfig: SpeechConfig, audioConfig?: AudioConfig)
參數
- speechConfig
- SpeechConfig
這個辨識器的初始屬性集
- audioConfig
- AudioConfig
與辨識器相關聯的選擇性音訊組態
屬性詳細資料
authorizationToken
取得用來與服務通訊的授權權杖。
string authorizationToken
屬性值
string
授權權杖。
canceled
事件已取消,表示辨識期間發生錯誤。
public canceled: (sender: Recognizer, event: SpeechRecognitionCanceledEventArgs) => void
屬性值
(sender: Recognizer, event: SpeechRecognitionCanceledEventArgs) => void
endpointId
取得用於語音辨識之自訂語音模型的端點識別碼。
string endpointId
屬性值
string
用於語音辨識之自訂語音模型的端點識別碼。
internalData
object internalData
屬性值
object
outputFormat
properties
為這個 SpeechRecognizer 定義的屬性及其值集合。
PropertyCollection properties
屬性值
為這個 SpeechRecognizer 定義的屬性及其值集合。
recognized
事件可辨識的訊號表示收到最終辨識結果。
public recognized: (sender: Recognizer, event: SpeechRecognitionEventArgs) => void
屬性值
(sender: Recognizer, event: SpeechRecognitionEventArgs) => void
recognizing
事件辨識訊號表示收到中繼辨識結果。
public recognizing: (sender: Recognizer, event: SpeechRecognitionEventArgs) => void
屬性值
(sender: Recognizer, event: SpeechRecognitionEventArgs) => void
speechRecognitionLanguage
取得辨識的口語語言。
string speechRecognitionLanguage
屬性值
string
辨識的口語。
telemetryEnabled
此方法會傳回遙測設定的目前狀態。
static boolean telemetryEnabled
屬性值
boolean
如果已啟用遙測,則為 true,否則為 false。
繼承的屬性詳細資料
sessionStarted
定義會話已啟動事件的事件處理常式。
public sessionStarted: (sender: Recognizer, event: SessionEventArgs) => void
屬性值
(sender: Recognizer, event: SessionEventArgs) => void
sessionStopped
定義會話已停止事件的事件處理常式。
public sessionStopped: (sender: Recognizer, event: SessionEventArgs) => void
屬性值
(sender: Recognizer, event: SessionEventArgs) => void
speechEndDetected
定義語音停止事件的事件處理常式。
public speechEndDetected: (sender: Recognizer, event: RecognitionEventArgs) => void
屬性值
(sender: Recognizer, event: RecognitionEventArgs) => void
speechStartDetected
定義語音啟動事件的事件處理常式。
public speechStartDetected: (sender: Recognizer, event: RecognitionEventArgs) => void
屬性值
(sender: Recognizer, event: RecognitionEventArgs) => void
方法詳細資料
close(() => void, (error: string) => void)
關閉這個類別實例所持有的所有外部資源。
function close(cb?: () => void, errorCb?: (error: string) => void)
參數
- cb
-
() => void
- errorCb
-
(error: string) => void
dispose(boolean)
處置 物件所持有的任何資源。
function dispose(disposing: boolean): Promise<void>
參數
- disposing
-
boolean
如果處置 物件,則為 true。
傳回
Promise<void>
FromConfig(SpeechConfig, AutoDetectSourceLanguageConfig, AudioConfig)
SpeechRecognizer 建構函式。
static function FromConfig(speechConfig: SpeechConfig, autoDetectSourceLanguageConfig: AutoDetectSourceLanguageConfig, audioConfig?: AudioConfig): SpeechRecognizer
參數
- speechConfig
- SpeechConfig
這個辨識器的初始屬性集
- autoDetectSourceLanguageConfig
- AutoDetectSourceLanguageConfig
與辨識器相關聯的來來源語言偵測組態
- audioConfig
- AudioConfig
與辨識器相關聯的選擇性音訊組態
傳回
recognizeOnceAsync((e: SpeechRecognitionResult) => void, (e: string) => void)
啟動語音辨識,並在辨識第一個語句之後停止。 此工作會傳回辨識文字作為結果。 注意:RecognizeOnceAsync () 會在辨識第一個語句時傳回,因此它只適用于單次辨識,例如命令或查詢。 針對長時間執行的辨識,請改用 StartContinuousRecognitionAsync () 。
function recognizeOnceAsync(cb?: (e: SpeechRecognitionResult) => void, err?: (e: string) => void)
參數
- cb
-
(e: SpeechRecognitionResult) => void
收到 SpeechRecognitionResult 的回呼。
- err
-
(e: string) => void
發生錯誤時叫用回呼。
startContinuousRecognitionAsync(() => void, (e: string) => void)
啟動語音辨識,直到呼叫 stopContinuousRecognitionAsync () 為止。 使用者必須訂閱事件,才能接收辨識結果。
function startContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void)
參數
- cb
-
() => void
一旦辨識啟動,就會叫用回呼。
- err
-
(e: string) => void
發生錯誤時叫用回呼。
startKeywordRecognitionAsync(KeywordRecognitionModel, () => void, (e: string) => void)
使用關鍵字點啟動語音辨識,直到呼叫 stopKeywordRecognitionAsync () 為止。 使用者必須訂閱事件,才能接收辨識結果。 注意:關鍵字辨識功能僅適用于語音裝置 SDK。 SDK 本身目前不包含這項功能。
function startKeywordRecognitionAsync(model: KeywordRecognitionModel, cb?: () => void, err?: (e: string) => void)
參數
- model
- KeywordRecognitionModel
關鍵字辨識模型,指定要辨識的關鍵字。
- cb
-
() => void
一旦辨識啟動,就會叫用回呼。
- err
-
(e: string) => void
發生錯誤時叫用回呼。
stopContinuousRecognitionAsync(() => void, (e: string) => void)
停止連續語音辨識。
function stopContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void)
參數
- cb
-
() => void
一旦辨識停止,就會叫用回呼。
- err
-
(e: string) => void
發生錯誤時叫用回呼。
stopKeywordRecognitionAsync(() => void)
停止連續語音辨識。 注意:關鍵字辨識功能僅適用于語音裝置 SDK。 SDK 本身目前不包含這項功能。
function stopKeywordRecognitionAsync(cb?: () => void)
參數
- cb
-
() => void
一旦辨識停止,就會叫用回呼。
繼承的方法的詳細資料
enableTelemetry(boolean)
這個方法會全域啟用或停用遙測。
static function enableTelemetry(enabled: boolean)
參數
- enabled
-
boolean
遙測集合的全域設定。 如果設定為 true,則會收集遙測資訊,例如麥克風錯誤、辨識錯誤並傳送給 Microsoft。 如果設定為 false,則不會將任何遙測傳送至 Microsoft。