///
import type { WaveProps } from '../../SoundWave';
/**
* 录音状态类型
*/
export type RecordingState = 'idle' | 'recording' | 'willCancel' | 'willSpeechToText';
/**
* SpeechToText 组件基础属性
*/
export interface SpeechToTextBaseProps {
/**
* 按住说话按钮文案(idle 状态显示)
* @type { string }
* @default '按住 说话'
*/
pressText?: string;
/**
* 语音转文字按钮文案
* @type { string }
* @default '语音转文字'
*/
speechToTextLabel?: string;
/**
* 取消按钮文案
* @type { string }
* @default '取消'
*/
cancelLabel?: string;
/**
* 未检测到说话时的提示文案
* @type { string }
* @default '请说话'
*/
speakingText?: string;
/**
* 检测到说话后的提示文案
* @type { string }
* @default '松手发送'
*/
recordingText?: string;
/**
* 取消状态提示文案(手指滑入取消区域时显示)
* @type { string }
* @default '松手取消'
*/
willCancelText?: string;
/**
* 语音转文字状态提示文案(手指滑入语音转文字按钮区域时显示)
* @type { string }
* @default '松手转文字'
*/
willSpeechToTextText?: string;
/**
* 倒计时提示文案(录音剩余时间不足10秒时显示)
* @type { string }
* @default '{seconds}s后将停止录音'
*/
countdownText?: string;
/**
* 取消录音回调
* @type { () => void }
* @default undefined
*/
onCancel?: () => void;
/**
* 音频变化回调
* @description 松手发送或语音转文字时触发,返回录音的 Blob 对象和类型
* @type { (blob: Blob, type: 'send' | 'speechToText') => void }
* @default undefined
*/
onChange?: (blob: Blob, type: 'send' | 'speechToText') => void;
/**
* 音波条配置
* @type { WaveProps }
* @default undefined
*/
waveProps?: Omit;
/**
* 音波条容器自定义类名
* @type { string }
* @default undefined
*/
waveContainerClassName?: string;
/**
* 是否显示 Halo 光环效果
* @type { boolean }
* @default true
*/
showHalo?: boolean;
/**
* 自定义样式
* @type { React.CSSProperties }
* @default undefined
*/
style?: React.CSSProperties;
/**
* 震动回调
* @description 在进入取消区域时触发,用户可自定义震动行为
* @type { (type?: 'countdown' | 'timeout' | 'cancel') => void }
* @default 使用 navigator.vibrate
*/
onVibrate?: (type?: 'countdown' | 'timeout' | 'cancel') => void;
/**
* 音频流变化回调
* @description 录音开始/结束时触发,供父组件(如 TextArea)在 input/textarea 下方渲染光圈
* @type { (stream: MediaStream | null) => void }
* @default undefined
*/
onStreamChange?: (stream: MediaStream | null) => void;
/**
* 录音状态变化回调
* @type { (state: RecordingState) => void }
* @default undefined
*/
onRecordingStateChange?: (state: RecordingState) => void;
}
/**
* SpeechToText 组件属性
* @description 支持直接传入各属性,或通过 allowAudio 传入配置对象
*/
export interface SpeechToTextProps extends SpeechToTextBaseProps {
/**
* 允许音频输入的配置
* @description 可以是 boolean(启用默认配置)或 SpeechToTextBaseProps 对象(自定义配置)
* @type { boolean | SpeechToTextBaseProps }
* @default undefined
*/
allowAudio?: boolean | SpeechToTextBaseProps;
/**
* 设置语音输入模式状态
* @description 录音结束后会自动调用 setIsAudio(false) 切换回文本模式
* @type { (isAudio: boolean) => void }
* @default undefined
*/
setIsAudio?: (isAudio: boolean) => void;
/**
* 设置是否显示 footer
* @description 录音开始时设置为 false,录音结束时设置为 true
* @type { (show: boolean) => void }
* @default undefined
*/
setShowFooter?: (show: boolean) => void;
}