首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将字节数组从Spring boot发送到angular应用程序?

将字节数组从Spring boot发送到angular应用程序?
EN

Stack Overflow用户
提问于 2018-03-27 04:20:20
回答 1查看 788关注 0票数 0

我用过一个AudioInputStream,我用MaryTTS把它从文本转换成语音。我想把这个音频发送给客户机角,在这种情况下,.How我可以做到这一点与http?我已经把音频放到了一个字节数组中,我如何发送它?

这个方法返回一个字节数组,想要将它发送到angular应用程序并播放音频.Any帮助吗?

代码语言:javascript
复制
public byte[] generateVoice( ) {


    LocalMaryInterface maryInterface = null;
    try {
        maryInterface = new LocalMaryInterface();
    } catch (MaryConfigurationException e) {
        System.err.println("Could not initialize MaryTTS interface: " + e.getMessage());
        e.printStackTrace();
    }

    try {
        if (maryInterface != null) audio = maryInterface.generateAudio("this is the first audio");

    } catch (SynthesisException e) {
        System.err.println("Synthesis failed: " + e.getMessage());

    }

    byte[] buffer = new byte[0];
    try {
        buffer = new byte[audio.available()];

        while ((audio.read(buffer)) != -1) {
            System.out.println("the buffer is being filled");
        }


    } catch (IOException e) {
        e.printStackTrace();
    }
    return buffer;

}
EN

回答 1

Stack Overflow用户

发布于 2018-03-27 05:08:14

你得做一条流。看一下:npm stream-buffer

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49499959

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档