简体   繁体   中英

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. 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:

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. I've used ModemManager to add qmi_wwan and enable audio through 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 . After that you can use a serial connection to stream audio data to the serial port.

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 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

Don't forget to disable xonxoff rtscts for serial.

I advise you to use dbus to communicate with 7600

https://github.com/Jude188/python-modemmanager

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM