Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tuxiaobei-scu opened this issue Feb 1, 2024 · 1 comment
Open

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

tuxiaobei-scu opened this issue Feb 1, 2024 · 1 comment

Comments

@tuxiaobei-scu
Copy link

电脑端:

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
Copy link
Contributor

cssxsh commented Feb 1, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants