Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Latest commit

 

History

History
38 lines (30 loc) · 1.07 KB

README.md

File metadata and controls

38 lines (30 loc) · 1.07 KB

本项目是基于 Azure 文本转语音服务 实现

使用方法:

添加依赖:

dependencies {
    implementation("top.limbang:text-to-speech:1.0.2")
}

编写 SSML 参考SSML语法

val ssml = createSSML().speak{
    voice(XiaoxiaoNeural()) {
        +"你好我是${it.localName}"
    }
}

val out = FileOutputStream("123.mp3")

runBlocking {
    // 需要在协程里面执行
    val speech = TTS.convert(ssml)
    if (speech.isNotEmpty()) withContext(Dispatchers.IO) {
        out.write(speech)
        out.flush()
        out.close()
    }
}