project-mirai / mirai-api-http

Mirai HTTP API (console) plugin
GNU Affero General Public License v3.0
1.66k stars 343 forks source link

发送语音电脑端无法播放,手机端却可以 #758

Open tuxiaobei-scu opened 9 months ago

tuxiaobei-scu commented 9 months ago

电脑端:

5d5557c1550063f59e1672ee38caf9ee

点击无法播放

手机端却可以正常播放

使用 Base64 传输语音,部分代码:

def wav_to_amr(input_wav, output_amr):
    os.system(f"sox {input_wav} -r 8000 -c 1 {output_amr}")
    with open(output_amr, 'rb') as f:
        audio = f.read()
    audio_base64 = base64.b64encode(audio)
    audio_str = audio_base64.decode('utf-8')
    return audio_str

voice_base64 = wav_to_amr('a.wav', 'b.amr-nb')
# {'type': 'Voice', 'base64': voice_base64}
cssxsh commented 9 months ago

https://github.com/mamoe/mirai/blob/3a8003057a593601dfe5a6dac3477503e29fc8a7/mirai-core-api/src/commonMain/kotlin/contact/Group.kt#L155-L167

QQ原生的语言格式是 amr 或 silk

可以尝试安装扩展插件 https://github.com/project-mirai/mirai-silk-converter