Working on voice playback

This commit is contained in:
Simon 2020-09-13 18:04:11 +01:00
parent dbe0fe7e0e
commit 4b5d069763
3 changed files with 32 additions and 3 deletions

View File

@ -33,7 +33,7 @@ This program currently only works with group voice calls.
# Python modules we need
import sys
from bitarray import bitarray
from time import time
from time import time,sleep
import importlib.util
# Twisted is pretty important, so I keep it separate
@ -43,11 +43,13 @@ from twisted.internet import reactor, task
# Things we import from the main hblink module
from hblink import HBSYSTEM, OPENBRIDGE, systems, hblink_handler, reportFactory, REPORT_OPCODES, mk_aliases
from dmr_utils3.utils import bytes_3, int_id, get_alias
from dmr_utils3.utils import bytes_3, int_id, get_alias, bytes_4
from dmr_utils3 import decode, bptc, const
import config
import log
from const import *
from mk_voice import pkt_gen
from voice_lib import words
# Stuff for socket reporting
import pickle
@ -526,7 +528,7 @@ class routerHBP(HBSYSTEM):
if (_stream_id != self.STATUS[_slot]['RX_STREAM_ID']):
logger.warning('(%s) Reflector: Private call from %s to %s',self._system, int_id(_rf_src), _int_dst_id)
#if _int_dst_id >= 4000 and _int_dst_id <= 5000:
if _int_dst_id >= 90 and _int_dst_id <= 99999:
if _int_dst_id >= 90 and _int_dst_id <= 999999:
_bridgename = '#'+ str(_int_dst_id)
if _bridgename not in BRIDGES and not (_int_dst_id >= 4000 and _int_dst_id <= 5000):
logger.info('(%s) Reflector for TG %s does not exist. Creating as User Activated',self._system, _int_dst_id)
@ -582,6 +584,28 @@ class routerHBP(HBSYSTEM):
_system['TIMER'] = pkt_time
logger.info('(%s) Reflector: %s set to ON with and "OFF" timer rule: timeout timer cancelled', self._system, _bridge)
if (_frame_type == HBPF_DATA_SYNC) and (_dtype_vseq == HBPF_SLT_VTERM) and (self.STATUS[_slot]['RX_TYPE'] != HBPF_SLT_VTERM):
speech = pkt_gen(bytes_3(2342690), bytes_3(9), bytes_4(2342690), 1, [words['all_circuits'],words['enabled']])
sleep(1)
while True:
try:
pkt = next(speech)
except StopIteration:
break
sleep(.058)
self.send_system(pkt)
#print(bhex(pkt))
sleep(1)
while True:
try:
pkt = next(speech)
except StopIteration:
break
sleep(.058)
self.send_system(pkt)
#print(bhex(pkt))
# Mark status variables for use later
self.STATUS[_slot]['RX_PEER'] = _peer_id
self.STATUS[_slot]['RX_SEQ'] = _seq

View File

@ -56,6 +56,7 @@ def pkt_gen(_rf_src, _dst_id, _peer, _slot, _phrase):
EMBED = []
EMBED.append( BS_VOICE_SYNC )
EMBED.append(EMB['BURST_A'][:8] + EMB_LC[1] + EMB['BURST_A'][-8:])
EMBED.append(EMB['BURST_B'][:8] + EMB_LC[1] + EMB['BURST_B'][-8:])
EMBED.append(EMB['BURST_C'][:8] + EMB_LC[2] + EMB['BURST_C'][-8:])
EMBED.append(EMB['BURST_D'][:8] + EMB_LC[3] + EMB['BURST_D'][-8:])

View File

@ -142,5 +142,9 @@ words = {
[bitarray('110100110000111000100101101001100100101010010010111011011001010110110011111100110100100101101000011011100000'), bitarray('001010011110000010110001000111011100110101100111110001001111011011100100000000000100011011010111110000100010')],
[bitarray('100000110100001001101101011110010011010000100010011100111111011010100011110101010110001111000011011100010111'), bitarray('011011101100111011011011010101011011000001001100101011101100001101111010111011111100010101100111001001110110')],
[bitarray('110101101110001110100111011001110010011011000000110100010011101010001000101101011011001100101001110010110010'), bitarray('010010000000010001111001001001100010101011001010101001000000001000000000000001000100010000001000000010000000')]
],
'silence': [
[bitarray('000000001010110000000000000000001010101000000000000000000100000000000000000000000010000000000000000000000'),
bitarray('0000000000000000000000001000100000000000000000001000000000000000000000010000000000000000000000010000000')]
]
}