Summary of the invention
The technical problem to be solved in the present invention is that in view of the deficiencies of the prior art, providing one kind and being based on DSP to the side TDM
The method and terminal for playing voice document increase terminal device to solve to need additional fpga chip in existing method
Production cost the problem of.
In order to solve the above-mentioned technical problem, the technical solution adopted in the present invention is as follows:
A method of voice document is played to the side TDM based on DSP comprising:
The first data packet that the channel DSP carries is obtained at interval of preset time, and institute is replaced using preset voice data
The first data packet is stated to generate the second data packet;
The source address in the channel DSP and destination address are exchanged, and second data packet is configured at the DSP and is led to
Second data packet is sent to media sheet processor by road;
Second data packet is sent on the time slot of TDM bus by the media sheet processor, by institute's predicate
Sound data playback is to the side TDM.
The method for playing voice document to the side TDM based on DSP, wherein described logical at interval of preset time acquisition DSP
The first data packet that road carries, and use preset voice data replacement first data packet to generate the second data packet before
Include:
Voice document to be sent in flash memory is obtained, and institute's voice file is stored in memory.
The method for playing voice document to the side TDM based on DSP, wherein described logical at interval of preset time acquisition DSP
The first data packet that road carries, and it is specific to generate the second data packet to use preset voice data to replace first data packet
Include:
The first data packet that the channel DSP carries is obtained at interval of preset time, wherein first data packet is RTP lattice
Formula;
The first byte of first data packet is obtained, and chooses the voice of corresponding first byte from institute's voice file
Data;
The voice data is used to replace the data in first data packet to generate the second data packet.
The method for playing voice document to the side TDM based on DSP, wherein described to obtain the of first data packet
One byte, and the voice data for choosing from institute's voice file corresponding first byte specifically includes:
The first byte of first data packet is obtained, and obtains the pointer position of institute's voice file;
The voice data of first byte is chosen since the pointer position, and the pointer position is inclined to last bit
Move first byte position.
The method for playing voice document to the side TDM based on DSP, wherein described to be chosen since the pointer position
The voice data of first byte, and the pointer position is specifically included to last bit offset first byte position:
The last bit of institute's voice file is obtained, and calculates the second byte of the pointer position Yu the last bit interval;
Second byte is compared with the first byte;
If second byte is more than or equal to first byte, first word is chosen since the pointer position
The voice data of section, and the pointer position is deviated into first byte position to last bit;
If second byte is less than first byte, the first voice number between pointer position and last bit is chosen
According to, and use the first voice data described in quiet data polishing to obtain voice data, and pointer position is offset to last bit
The last bit.
The method for playing voice document to the side TDM based on DSP, wherein described to be chosen since the pointer position
The voice data of first byte, and by the pointer position to last bit deviate first byte position after further include:
Judge whether the pointer position is in the last bit of institute's voice file, and at which when last bit, described in closing
The channel DSP.
The method for playing voice document to the side TDM based on DSP, wherein described logical at interval of preset time acquisition DSP
The first data packet that road carries, and it is specific to generate the second data packet to use preset voice data to replace first data packet
Include:
The first data packet that the channel DSP carries, and the detection when receiving the first data packet are obtained at interval of preset time
The voice document mark that the channel DSP carries;
When institute's voice file is identified as default mark, use preset voice data replace first data packet with
Generate the second data.
It is described based on DSP to the side TDM play voice document method, wherein the source address by the channel DSP with
Destination address exchange, and second data packet is configured at the channel DSP, after playing voice to the side TDM further include:
The source address and destination address in the channel DSP are restored, and obtains number from TDM bus at interval of preset time
According to;
The data are compiled to generate the first data packet, and first data packet is sent by the channel DSP.
A kind of storage medium, is stored with a plurality of instruction, and described instruction is suitable for being loaded by processor and being executed as described above
The method for playing voice document to the side TDM based on DSP.
A kind of terminal comprising:
Processor is adapted for carrying out each instruction;And
Equipment is stored, is suitable for storing a plurality of instruction, described instruction is suitable for being loaded by processor and being executed as above any described
The method for playing voice document to the side TDM based on DSP.
The utility model has the advantages that compared with prior art, playing voice document to the side TDM based on DSP the present invention provides a kind of
Method and terminal, the method between media sheet processor and mainboard processor by establishing a channel DSP, mainboard processor
The first data packet that the channel DSP is sent is received at interval of preset time, and described ground data are replaced using preset voice data
Data in packet obtain the second data packet, later in the source address and destination address for exchanging the channel DSP, with logical by the DSP
Second data packet is sent to media plate processing by road, and second data packet is sent to TDM by media sheet processor
On the time slot of bus, to playing the voice data that second data packet carries to TDM.The present embodiment is only by mainboard
It establishes between processor and media plate processing with the channel DSP, is achieved that and thinks that the side TDM plays voice, without installing fpga chip,
Cost is saved.Meanwhile also do not limited by the memory inside DSP for storaged voice file, improve voice broadcasting at
Power.
Specific embodiment
The present invention provides a kind of method and terminal for playing voice document to the side TDM based on DSP, to make mesh of the invention
, technical solution and effect it is clearer, clear, the present invention is described in more detail as follows in conjunction with drawings and embodiments.
It should be appreciated that described herein, specific examples are only used to explain the present invention, is not intended to limit the present invention.
Those skilled in the art of the present technique are appreciated that unless expressly stated, singular " one " used herein, " one
It is a ", " described " and "the" may also comprise plural form.It is to be further understood that being arranged used in specification of the invention
Diction " comprising " refer to that there are the feature, integer, step, operation, element and/or component, but it is not excluded that in the presence of or addition
Other one or more features, integer, step, operation, element, component and/or their group.It should be understood that when we claim member
Part is " connected " or when " coupled " to another element, it can be directly connected or coupled to other elements, or there may also be
Intermediary element.In addition, " connection " used herein or " coupling " may include being wirelessly connected or wirelessly coupling.It is used herein to arrange
Diction "and/or" includes one or more associated wholes for listing item or any cell and all combinations.
Those skilled in the art of the present technique are appreciated that unless otherwise defined, all terms used herein (including technology art
Language and scientific term), there is meaning identical with the general understanding of those of ordinary skill in fields of the present invention.Should also
Understand, those terms such as defined in the general dictionary, it should be understood that have in the context of the prior art
The consistent meaning of meaning, and unless idealization or meaning too formal otherwise will not be used by specific definitions as here
To explain.
With reference to the accompanying drawing, by the description of the embodiment, further explanation of the contents of the invention are made.
Fig. 1 is please referred to, Fig. 1 is the preferable implementation of the method provided by the invention for playing voice document to the side TDM based on DSP
The flow chart of example.The described method includes:
S100, the first data packet that the channel DSP carries is obtained at interval of preset time, and replaced using preset voice data
First data packet is changed to generate the second data packet;
S200, the source address in the channel DSP and destination address are exchanged, and second data packet is configured at described
Second data packet is sent to media sheet processor by the channel DSP;
S300, second data packet is sent on the time slot of TDM bus by the media sheet processor, by institute
Predicate sound data playback is to the side TDM.
A kind of method that voice document is played to the side TDM based on DSP is present embodiments provided, by handling in media plate
A channel DSP is established between device and mainboard processor, mainboard processor receives the first of the transmission of the channel DSP at interval of preset time
Data packet, and the data in described ground data packet are replaced using preset voice data and obtain the second data packet, it is exchanging later
The source address and destination address in the channel DSP, second data packet is sent to media plate processing by the channel DSP,
Second data packet is sent on the time slot of TDM bus by media sheet processor, so that second data packet be taken
The voice data of band is played to TDM.The present embodiment is only logical with DSP by establishing between mainboard processor and media plate processing
Road is achieved that and thinks that the side TDM plays voice and saved cost without installing fpga chip.Meanwhile it not also being used for by the inside DSP
The limitation of the memory of storaged voice file improves the success rate of voice broadcasting.
Specifically, in the step S100, the channel DSP is between media sheet processor and mainboard processor
Channel, the source address in the channel DSP is the MAC Address of media plate, and destination address is the MAC Address of main sheet processor, and
And the source address and destination address just configure completion in the DSP Path Setup.Correspondingly, it is described at interval of it is default when
Between obtain the channel DSP carry the first data packet be main sheet processor at interval of preset time obtain the channel DSP carry first
Data packet.
First data packet is that media plate processing is sent by the channel DSP to mainboard processor, and it is the matchmaker
The data that body sheet processor is obtained from the time slot of TDM bus, and obtained after compiling.Correspondingly, the step S100
May include: before
S10, when receive to the side TDM play voice document instruction when, establish mainboard processor and media sheet processor
Between the channel DSP;
S20, data are read from the time slot of TDM bus by media sheet processor, and the data read is compiled
It translates to obtain the first data packet of RPT format;
S30, first data packet is sent to mainboard processor by DSP.
Specifically, the compiling RTP formatted file is encoded using PCMA, and code rate is the RTP packing of 64Kbps and configuration
Shi Changwei 20ms.That is, carrying out PCMA coding to the data that media sheet processor is read needs 20ms, i.e., most fast every 20ms
Generate first data packet of a RTP format.It is taken correspondingly, mainboard processor can receive a channel DSP at interval of 20ms
First data packet of band, also, the media sheet processor also sends one second at interval of 20ms on the time slot of TDM bus
Data packet, and data interaction is carried out to read one for being compiled as the first data with TDM bus when sending the second data packet
The data of packet send first data packet to mainboard processor at interval of 20ms to realize the channel DSP.
Further, the voice data is the voice to be played to the side TDM being pre-stored in mainboard processor memory
The content of file.And in practical applications, voice document is stored in mainboard processor can occupy the content of mainboard processor, and
Mainboard processor memory is influenced in order to avoid voice document plays, voice document flash memory can be stored in, work as needs
When voice document is played to the side TDM, voice document is being read from flash memory.Correspondingly, described at interval of preset time
The first data packet that the channel DSP carries is obtained, and preset voice data is used to replace first data packet to generate second
Include: before data packet
S01, voice document to be sent in flash memory is obtained, and institute's voice file is stored in memory.
Specifically, mainboard processor accesses flash memory by system bus, and read in flash storage to
It is sent to the voice document of the side TDM, and institute's voice file is cached in the memory of mainboard processor, is broadcast to institute's voice file
After putting, it is deleted from the memory of mainboard processor, in order to avoid occupy mainboard processor memory.
Further, since second data packet is the content replaced in the second data packet using voice data, thus institute
The byte for stating the second data packet is identical as the byte needs of the second data packet, to need during generating the second data packet
The byte of the first data packet is obtained, and chooses the voice data of respective byte according to the byte, to generate second number
According to packet.
Illustratively, described that the first data packet that the channel DSP carries is obtained at interval of preset time, and use preset language
Sound data are replaced first data packet and are specifically included with generating the second data packet:
S101, the first data packet that the channel DSP carries is obtained at interval of preset time, wherein first data packet is
RTP format;
S102, the first byte for obtaining first data packet, and corresponding first byte is chosen from institute's voice file
Voice data;
S103, the voice data is used to replace the data in first data packet to generate the second data packet.
Specifically, first data packet is the data packet of the RTP format generated by PCMA coding, first data
The payload of packet is 160 bytes, wherein a byte number is 64*1000/8=8000byte/s, and 20 byte number is 8000*20/
1000=160 bytes.Correspondingly, second data packet is also 160 bytes.
Further, since the byte of the voice document obtained in mainboard processor from flash memory is possibly more than 160 words
Section, to need to choose the voice data of 160 bytes in voice document every time, to generate the second data packet.In this embodiment,
The selection of the voice data successively chooses 160 words using the pointer position of voice document as starting point, from the starting point backward
Section, and pointer position is deviated into 160 bytes.
Illustratively, first byte for obtaining first data packet, and chosen accordingly from institute's voice file
The voice data of first byte number specifically includes:
S1021, the first byte for obtaining first data packet, and obtain the pointer position of institute's voice file;
S1022, the voice data that first byte is chosen since the pointer position, and by the pointer position to
Last bit deviates first byte position.
Specifically, need to judge the finger before the voice data of first byte is chosen since the pointer position
Whether the byte of the data between pin position and voice document last bit is greater than the first byte, because only that in pointer position and voice
When the byte of data between file last bit is greater than the first byte, the voice data to the first byte could be chosen.Correspondingly, institute
The voice data that first byte is chosen since the pointer position is stated, and by the pointer position to described in last bit offset
First byte position specifically includes:
H10, the last bit for obtaining institute's voice file, and calculate the second word of the pointer position Yu the last bit interval
Section;
H20, second byte is compared with the first byte;
If H30, second byte are more than or equal to first byte, described the is chosen since the pointer position
The voice data of one byte, and the pointer position is deviated into first byte position to last bit;
If H40, second byte are less than first byte, the first voice between pointer position and last bit is chosen
Data, and use the first voice data described in quiet data polishing to obtain voice data, and pointer position is deviated to last bit
To the last bit.
Specifically, described to refer to the second byte subtracting the first word using the first voice data described in quiet data polishing
It, so both can be with to obtain the first voice data of the first byte after the quiet data of section replenishes the voice data of selection
The data that will be replaced using the first voice data of quiet data polishing in the first data packet, and the side TDM can be made not connect
It is played to other voices outside voice document.
In one embodiment of this law invention, the voice that first byte is chosen since the pointer position
Data, and by the pointer position to last bit deviate first byte position after further include:
Judge whether the pointer position is in the last bit of institute's voice file, and at which when last bit, described in closing
The channel DSP.
Specifically, the last bit for judging whether the pointer position is in institute's voice file is to judge the voice text
Whether part finishes.In practical applications, can be sentenced according to the length of voice document and the positional shift of voice document pointer
Whether disconnected file finishes, and is turned off the channel DSP to upper-layer service with regard to reporting message if finishing, does not finish
Wait for next RTP packet.
Further, since the channel DSP on media plate is there are two types of operating mode, respectively speech pattern and voice document
Play mode, and when needing to play voice document and opening the channel DSP, voice text can be incidentally played for the channel DSP
The voice document of part identifies.Institute's voice file is identified as software parameter, for example, the software parameter is 0 expression speech pattern,
Voice document play mode is indicated for 1.Correspondingly, described obtain the first data packet that the channel DSP carries at interval of preset time,
And it uses preset voice data to replace first data packet and is specifically included with generating the second data packet:
S101a, the first data packet that the channel DSP carries is obtained at interval of preset time, and is receiving the first data packet
When detect the voice document mark that the channel DSP carries;
S102a, when institute's voice file is identified as default mark, the data packet is replaced using preset voice data
To generate the second data.
Specifically, when mainboard processor receives RTP packet, check that the voice document in the channel DSP identifies whether as voice
The mark of file play mode takes in 160 bytes if it is voice document play mode is played since voice document pointer
Hold to replace the payload of 160 bytes in RTP packet, generates the second data packet, second data packet is also RTP format.
Further, in the step S200, the source address by the channel DSP refers to obtaining with destination address exchange
The source address and destination address that the channel DSP carries, and source address is changed to destination address, with being changed to source by destination address
Location, so that the direction of the DSP channel transfer file is changed into from source address to destination address transmission from destination address to source
Second data packet is sent to media plate to realize by address transmission.In the present embodiment, by source address and destination address to being changed to
Source address is changed to mainboard processor address, destination address is changed to media plate processor address, passes through the channel DSP mesh in this way
The exchange for marking address and source address, realizes the transmitted in both directions in the channel DSP.
Further, in the step S300, on the time slot that the second data packet is sent to TDM bus, to pass through
The TDM bus plays second data packet to the side TDM.And in practical applications, when media sheet processor is counted second
When being sent on the time slot of TDM bus according to packet, data identical with the second data packet byte are obtained from the time slot of TDM bus,
And the data of acquisition are compiled to obtain the first data packet, to realize between mainboard processor and media sheet processor
Data are back and forth sent, so as to transmit the voice document of different length by the channel DSP, and by institute's voice file
It plays to the side TDM.
Further, since exchange source address and destination address when the second data packet is sent to media sheet processor, that
After media version processor obtains and generates the first data packet, need to restore the destination address in the channel DSP and source address, with
The first data packet is sent to mainboard processor by the channel DSP.Correspondingly, the source address by the channel DSP
It is exchanged with destination address, and second data packet is configured at the channel DSP, also wrapped later with playing voice to the side TDM
It includes:
S400, the source address and destination address for restoring the channel DSP, and obtained from TDM bus at interval of preset time
Access evidence;
S500, the compiling data send first data by the channel DSP to generate the first data packet
Packet.
Specifically, the preset time is identical as the mainboard processor reception interval time of the first data packet, for example, being
20ms。
The present invention also provides a kind of storage mediums, are stored with a plurality of instruction, and described instruction is suitable for being loaded by processor
And execute as above any method that voice document is played to the side TDM based on DSP.
The present invention also provides a kind of terminals, as shown in Figure 2 comprising at least one processor (processor) 20 with
And memory (memory) 22, it can also include display screen 21, communication interface (Communications Interface) 23 Hes
Bus 24.Wherein, processor 20, display screen 21, memory 22 and communication interface 23 can be completed mutual by bus 24
Communication.Display screen 21 is set as preset user in display initial setting mode and guides interface.Communication interface 23 can transmit letter
Breath.Processor 20 can call the logical order in memory 22, to execute the method in above-described embodiment.
In addition, the logical order in above-mentioned memory 22 can be realized and as only by way of SFU software functional unit
Vertical product when selling or using, can store in a computer readable storage medium.
Memory 22 is used as a kind of computer readable storage medium, and it is executable to may be configured as storage software program, computer
Program, such as the corresponding program instruction of method or module in the embodiment of the present disclosure.Processor 30 is stored in memory by operation
Software program, instruction or module in 22, thereby executing functional application and data processing, i.e. side in realization above-described embodiment
Method.
Memory 22 may include storing program area and storage data area, wherein storing program area can storage program area, extremely
Application program needed for a few function;Storage data area, which can be stored, uses created data etc. according to terminal device.This
Outside, memory 22 may include high-speed random access memory, can also include nonvolatile memory.For example, USB flash disk, movement
Hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory,
RAM), a variety of media that can store program code such as magnetic or disk, are also possible to transitory memory medium.
In addition, a plurality of instruction processing unit in above-mentioned storage medium and terminal loads and the detailed process that executes is above-mentioned
It has been described in detail in method, has just no longer stated one by one herein.
Finally, it should be noted that the above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although
Present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that: it still may be used
To modify the technical solutions described in the foregoing embodiments or equivalent replacement of some of the technical features;
And these are modified or replaceed, technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution spirit and
Range.