node.js - 从 Flutter 录制音频数据(16000Hz PCM 数据),捕获音频并将其发送到后端(Node.js)
问题描述
我正在尝试通过pub.dev中的 mic_stream 包录制音频(因为我想要 16000Hz PCM 数据),并尝试捕获数据并将其发送到 Nodejs 服务器。我没有对提供的链接中的 mic_stream 示例进行任何更改,但我想将 16000Hz PCM 格式的音频数据发送到 Nodejs 服务器。我尝试使用 http.MultipartFile ,如下所示:
var url = Uri.parse("http://localhost:3000/upload");
var request = new http.MultipartRequest("POST", url);
Future<int> length = stream.length;
var stream_length = http.ByteStream(stream);
request.files.add( await http.MultipartFile('music',stream,length,{
"filename1234.pcm"), new MediaType('audio', 'x-wav')});
//This gives me error because length is not of int type
request.send().then((response) {
print("test");
if (response.statusCode == 200) print("Uploaded! ${response}");
else print("Failure");
});
我想知道这是否可行,或者是否有任何其他包可用于记录数据并以 PCM 格式 16000Hz 发送到 Nodejs。非常感谢任何帮助。
解决方案
推荐阅读
- java - 数据库数据未在应用程序中更新
- pentaho - kettke 转换(作业)的主键错误的重复条目
- java - 当方法永远不会抛出异常时,为什么编译器允许抛出异常
- php - 如何使用 Laravel 在远程服务器上提取 zip 文件?
- kubernetes - 调用 helm install 时 Celery 任务停止
- swift - 我可以在 Swift 中编写类型吗?
- android - 如何设计用于在 SMS 中发送大量内容的正文?
- c# - 数字签名文档中的结束标签
- mysql - 这个 MySQL 转置组是否可优化?
- javascript - npm install --production --prefix 给出错误