mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-06-02 00:57:41 +08:00
feat(wechatcom): add support for sending voice messages
This commit is contained in:
@@ -69,6 +69,24 @@ def any_to_sil(any_path, sil_path):
|
||||
raise NotImplementedError("Not support file type: {}".format(any_path))
|
||||
|
||||
|
||||
def any_to_amr(any_path, amr_path):
|
||||
"""
|
||||
把任意格式转成amr文件
|
||||
"""
|
||||
if any_path.endswith(".amr"):
|
||||
shutil.copy2(any_path, amr_path)
|
||||
return
|
||||
if (
|
||||
any_path.endswith(".sil")
|
||||
or any_path.endswith(".silk")
|
||||
or any_path.endswith(".slk")
|
||||
):
|
||||
raise NotImplementedError("Not support file type: {}".format(any_path))
|
||||
audio = AudioSegment.from_file(any_path)
|
||||
audio = audio.set_frame_rate(8000) # only support 8000
|
||||
audio.export(amr_path, format="amr")
|
||||
|
||||
|
||||
def mp3_to_wav(mp3_path, wav_path):
|
||||
"""
|
||||
把mp3格式转成pcm文件
|
||||
|
||||
Reference in New Issue
Block a user