[英]Play pre-recorded audio into a voice call that created by simcom
Currently, I'm working with simcom SIM7600G-H (using AT-command set) to create the voice call to notice user about some specified notifications.目前,我正在使用 simcom SIM7600G-H(使用 AT 命令集)创建语音呼叫以通知用户一些指定的通知。 I'm able to create voice call and hang up it, but don't know how to play a pre-recorded audio into it.
我可以创建语音通话并将其挂断,但不知道如何在其中播放预先录制的音频。 Is there anyway to perform that task.
无论如何要执行该任务。 My code to create voice call with simcom is below:
我使用 simcom 创建语音通话的代码如下:
import serial
import time
ser = serial.Serial("COM5", 115200)
ser.flushInput()
phone_number = '09xxxxxxx'
text_message = 'test simcom 7600'
def checkStart():
while True:
ser.write(('AT\r\n').encode())
time.sleep(0.1)
if ser.inWaiting():
time.sleep(0.01)
recBuff = ser.read(ser.inWaiting())
print('try to start\r\n' + recBuff.decode() )
print(recBuff.decode())
if 'OK' in recBuff.decode():
print("ok")
recBuff = ''
return
else:
time.sleep(1)
def sendAt(command,back,timeout):
rec_buff = ''
ser.write((command+'\r\n').encode())
time.sleep(timeout)
if ser.inWaiting():
time.sleep(0.01 )
rec_buff = ser.read(ser.inWaiting())
if back not in rec_buff.decode():
print(command + ' ERROR')
print(command + ' back:\t' + rec_buff.decode())
return 0
else:
print(rec_buff.decode())
return 1
def PhoneCall(phone_number):
sendAt('ATD'+phone_number+';','OK',1)
time.sleep(20)
ser.write('AT+CHUP\r\n'.encode())
print('Call disconnected')
try:
checkStart()
PhoneCall(phone_number)
time.sleep(20)
sendAt("ATH")
except:
print("Unable to connect!")
if ser != None:
ser.close()
I've been busy with the same issue.我一直忙于同样的问题。 I've used the QMI interface to enable PCM.
我已经使用 QMI 接口来启用 PCM。 I've used ModemManager to add qmi_wwan and enable audio through QMI.
我使用 ModemManager 添加 qmi_wwan 并通过 QMI 启用音频。 When you got that working with ModemManager
mmcli -m 0
will show you an audio serial port on probably /dev/ttyUSB4
To enable PCM on the 7600 you should execute AT+CPCMREG=1
.当您使用 ModemManager
mmcli -m 0
时,可能会在/dev/ttyUSB4
上向您显示音频串行端口。要在 7600 上启用 PCM,您应该执行AT+CPCMREG=1
。 After that you can use a serial connection to stream audio data to the serial port.之后就可以使用串口将stream音频数据连接到串口。
https://simcom.ee/documents/SIM7X00/SIM7100_SIM7500_SIM7600%20Series_USB%20AUDIO_Application%20Note_V1.03.pdf https://simcom.ee/documents/SIM7X00/SIM7100_SIM7500_SIM7600%20Series_USB%20AUDIO_Application%20Note_V1.03.pdf
I used sox to convert the audio data to the 8k 16 bit format:我使用 sox 将音频数据转换为 8k 16 位格式:
sox input.wav -r 8000 -b 16 out.wav
You could use wave to load in the wave file https://docs.python.org/3/library/wave.html您可以使用 wave 加载波形文件https://docs.python.org/3/library/wave.html
Don't forget to disable xonxoff
rtscts
for serial.不要忘记为串行禁用
xonxoff
rtscts
。
I advise you to use dbus to communicate with 7600建议你用dbus和7600通信
https://github.com/Jude188/python-modemmanager https://github.com/Jude188/python-modemmanager
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.