@minto-ai/huoshan-tts
Version:
借助“火山引擎在线语音合成API”实现浏览器端“文本转语音
160 lines (133 loc) • 2.31 kB
text/typescript
import type { PronunciationRuleList } from '../utils'
/**
* 平台系统配置
*/
interface SystemConfig {
/**
* TTS请求基础URL
*/
readonly ttsRequestBaseUrl: string
}
/**
* 业务参数接口
*/
interface BusinessParams {
/**
* 文本类型
*/
text_type?: 'plain' | 'ssml'
/**
* 音色类型
*/
voice_type?: string
/**
* 语速
* [0.2,3],默认为1,通常保留一位小数即可
*/
speed_ratio?: number
/**
* 音高
* [0.1, 3],默认为1,通常保留一位小数即可
*/
volume_ratio?: number
/**
* [0.1, 3],默认为1,通常保留一位小数即可
*/
pitch_ratio?: number
/**
* 是否流式发返回
*/
stream?: boolean
/**
* 语言类型
*/
language?: string
/**
* 供应商Id
*/
provider?: string
/**
* 是否使用缓存
*/
cache?: boolean
/**
* wav / pcm / ogg_opus / mp3,默认为 mp3
*/
encoding?: string
/**
* 输出格式
*/
output_format?: string
}
/**
* Ssml 配置接口
*/
interface SsmlConfig {
/**
* 发音规则
*/
pronunciationRules?: PronunciationRuleList
}
/**
* 内部使用的事件名称
*/
type PrivateCustomEventName
/**
* 文本切割
*/
= | '_textSplitFinish'
/**
* 创建Ssml
*/
| '_createSsmlFinish'
/**
* 音频播放执行
*/
| '_audioActuatorFinish'
| '_audioActuatorBeforeFirstExecute'
/**
* 当前整个应用
*/
| '_appError'
| '_appFinish'
/**
* 解码数据执行
*/
| '_decodeDataFinish'
/**
* tts请求执行
*/
| '_ttsRequestFinish'
/**
* 字节流缓存
*/
| '_byteBufferFinish'
/**
* 包装Audio实例
*/
| '_packAudioFinish'
/**
* 对外暴露的事件名称
*/
type PublicCustomEventName
= | 'appError'
| 'appFinish'
| 'audioFirstStart'
enum SystemStatus {
/**
* 空闲状态
*/
OFFLINE = 'offline',
/**
* 执行中
*/
EXECUTE = 'execute',
}
export type {
BusinessParams,
PrivateCustomEventName,
PublicCustomEventName,
SsmlConfig,
SystemConfig,
}
export { SystemStatus }