UNPKG

xfyun-sdk

Version:

科大讯飞语音识别 SDK,支持浏览器中实时语音听写功能

50 lines (49 loc) 1.35 kB
/** * 语音识别 React 组件 * * 基于 xfyun-sdk 的语音识别 UI 组件 * 使用共享模块减少代码重复 */ import React from 'react'; export interface SpeechRecognizerProps { /** 讯飞应用 ID */ appId: string; /** 讯飞 API Key */ apiKey: string; /** 讯飞 API Secret */ apiSecret: string; /** 语言 */ language?: 'zh_cn' | 'en_us'; /** 领域 */ domain?: 'iat' | 'medical' | 'assistant'; /** 口音 */ accent?: 'mandarin' | 'cantonese'; /** 热词 */ hotWords?: string[]; /** 是否启用标点 */ punctuation?: boolean; /** 是否自动开始 */ autoStart?: boolean; /** 开始回调 */ onStart?: () => void; /** 停止回调 */ onStop?: () => void; /** 识别结果回调 */ onResult?: (text: string, isEnd: boolean) => void; /** 错误回调 */ onError?: (error: unknown) => void; /** 组件类名 */ className?: string; /** 按钮类名 */ buttonClassName?: string; /** 开始按钮文本 */ buttonStartText?: string; /** 停止按钮文本 */ buttonStopText?: string; /** 是否显示音量条 */ showVolume?: boolean; /** 是否显示状态 */ showStatus?: boolean; } declare const SpeechRecognizer: React.FC<SpeechRecognizerProps>; export default SpeechRecognizer;