Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

您好,可以给个网络音频URL保存到本地,并驱动数字人说话的代码示例嘛 #20

Open
xkkjiayou opened this issue Jun 20, 2024 · 2 comments

Comments

@xkkjiayou
Copy link

您好,这个项目实在太伟大了,感谢技术专家们!!!
可以给个网络音频URL保存到本地,并驱动数字人说话的代码示例嘛

我看代码应该是在这里二次开发,但是不知道具体怎么做,方便给一些示例嘛,感谢

private fun playWav() {
        val wavName = "trans_7d9e53e8-2ece-11ef-bb8e-923c94a1fa2c.wav"
        val wavDir = File(mContext.getExternalFilesDir("duix"), "wav")
        if (!wavDir.exists()) {
            wavDir.mkdirs()
        }
        val wavFile = File(wavDir, wavName)
        if (!wavFile.exists()) {
            // 拷贝到sdcard
            val executor = Executors.newSingleThreadExecutor()
            executor.execute {
                val input = mContext.assets.open("wav/${wavName}")
                val out: OutputStream = FileOutputStream("${wavFile.absolutePath}.tmp")
                val buffer = ByteArray(1024)
                var read: Int
                while (input.read(buffer).also { read = it } != -1) {
                    out.write(buffer, 0, read)
                }
                input.close()
                out.close()
                File("${wavFile.absolutePath}.tmp").renameTo(wavFile)
                duix?.playAudio(wavFile.absolutePath)
            }
        } else {
            duix?.playAudio(wavFile.absolutePath)
        }
    }
@NodeGIS
Copy link

NodeGIS commented Jun 20, 2024

很棒的项目 最近刚刚完整走通, 没想到音频驱动效果这么好

@4yanzhen
Copy link

很棒的项目 最近刚刚完整走通, 没想到音频驱动效果这么好

好个锤子,口型都对不上

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants