如何从 android 接收 3gp 文件并使用 python 对其进行解码?
How to receive 3gp file from android and decode it using python?
我正在尝试从 android 接收一个 3gp 文件并使用其中的值在我的服务器中推断机器学习模型。服务器代码在 python.
当我使用下面的代码打开收到的文件时,
AudioSegment.from_file(BytesIO(posted_data), format="3gp")
输出值对于普通音频来说太大了。
我认为这是因为 android 使用 MediaRecorder 的 AMR_NB 编解码器对值进行编码,但未在服务器中正确解码。无论如何我可以正确解码我在 python 服务器中收到的字节吗?
FFmpeg is widely recognized as a Swiss army knife of audio/video conversion. It has Python bindings. I don't know the quality of those bindings, but if the conversion is meant as a one-off thing, you could also consider using the very mature FFmpeg program to convert your file to uncompressed audio (like WAV) before processing it with your code. Even the Python standard library can deal with WAV.
我正在尝试从 android 接收一个 3gp 文件并使用其中的值在我的服务器中推断机器学习模型。服务器代码在 python.
当我使用下面的代码打开收到的文件时,
AudioSegment.from_file(BytesIO(posted_data), format="3gp")
输出值对于普通音频来说太大了。 我认为这是因为 android 使用 MediaRecorder 的 AMR_NB 编解码器对值进行编码,但未在服务器中正确解码。无论如何我可以正确解码我在 python 服务器中收到的字节吗?
FFmpeg is widely recognized as a Swiss army knife of audio/video conversion. It has Python bindings. I don't know the quality of those bindings, but if the conversion is meant as a one-off thing, you could also consider using the very mature FFmpeg program to convert your file to uncompressed audio (like WAV) before processing it with your code. Even the Python standard library can deal with WAV.