Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic view of an application environment according to an embodiment of the present invention. As shown in fig. 1, the application environment includes a translator 10, a mobile terminal 20, and a server 30, and it is assumed that two parties of a conversation are a conversation person a and a conversation person B, and the conversation person a and the conversation person B perform speech communication through the translator 10; the native language of the dialog person a is chinese, the native language of the dialog person B is german, the dialog person a or the dialog person B may interact with the mobile terminal 20 through one or more user interaction devices of any suitable type, such as a mouse, a key, a remote controller, a touch screen, a motion sensing camera, an intelligent wearable device, etc., input an instruction or control the mobile terminal 20 to perform one or more operations, the mobile terminal 20 may be an intelligent electronic device of any suitable type, such as a smart phone, a tablet computer, a personal computer, a laptop computer, a PDA, or other mobile terminals, and the terminal mobile 20 may install or run a plurality of application programs (APP) such as translation software, multimedia playing software, etc.
The translator 10 and the mobile terminal 20 both have wireless communication modules to realize functions of wireless communication connection, information interaction, data transmission and the like between the two, the wireless communication modules include but are not limited to a bluetooth communication module, a WIFI communication module, a ZigBee (ZigBee) communication module and the like, and the mobile terminal 20 and the server 30 can be in communication connection or information interaction with the server 30 through 2G, 3G, 4G, 5G or wireless access points.
The server 30 may be a single physical server or a logical server formed by virtualizing a plurality of physical servers, or may be a server group formed by a plurality of servers capable of communicating with each other.
The specific usage scenarios are as follows:
assuming that the dialer a is a chinese, the dialer B is a german, the chinese and the german communicate with each other through the translator 10, the translator 10 is held by the chinese, the translator 10 has established a wireless communication connection with the mobile terminal 20, the terminal device 20 is running a translation APP, and a native language and a target language to be translated (the native language is chinese and the target language is german) are preset at the APP end.
Chinese enters a section of voice data through the translator 10, the translator 10 sends the voice data to the mobile terminal 20, the mobile terminal 20 encapsulates the voice data, Chinese identification and German identification into a translation request and sends the translation request to the server 30, the server 30 generates a translation result according to the translation request and sends the translation result to the mobile terminal 20, the translation result comprises Chinese characters and German characters, the mobile terminal 20 encodes the Chinese characters and the German characters to obtain encoded Chinese characters and German characters and sends the encoded Chinese characters and German characters to the translator 10, the translator 10 decodes the encoded Chinese characters and German characters and displays the German characters and the Chinese characters respectively, and German can know the meaning of Chinese according to the display content on the translator 10.
When the german speaks, the translator 10 is connected from the Chinese person, similarly, a section of voice data is input through the translator 10, the native language and the target language to be translated (the native language is german and the target language is Chinese) are also set at the APP, the voice data finally displays the Chinese characters and the german characters on the translator 10 through the processing process, and the Chinese person also knows the meaning to be expressed by the german through the display content on the translator 10. It is understood that the native and target languages are relative only and may each be any language in the world, such as english, latin, arabic, japanese, french, russian, and so forth.
Referring to fig. 2, fig. 2 is a schematic diagram of a translation system according to an embodiment of the present invention. As shown in fig. 1, the translation system 100 includes a translator 10, a mobile terminal 20 and a server 30, the translator 10 is configured to obtain voice data to be translated, the mobile terminal 20 is communicatively connected to the translator 10 and configured to encapsulate the voice data, a native language identifier and a target language identifier into a translation request, the server 30 is communicatively connected to the mobile terminal 20 and configured to generate a translation result according to the translation request and send the translation result to the mobile terminal 20, the translation result includes a native language text and a translated text, wherein the native language text is a text corresponding to the native language identifier, the translated text is a text corresponding to the target language identifier, the mobile terminal 20 performs encoding processing on the translation result to obtain translated data and send the translated data to the translator 10, the translator 10 performs decoding processing on the translated data, and displaying the decoded translation data.
In the embodiment of the invention, the voice data to be translated can be collected through a voice collecting module on the translator 10, such as a microphone, and when the voice data needs to be recorded, a speaker can speak towards the microphone so that the translator 10 can obtain the voice data; the communication connection mode between the translator 10 and the mobile terminal 20 may be wireless communication connection, such as bluetooth, WIFI, ZigBee, etc., and the communication connection mode between the mobile terminal 20 and the server 30 may be 2G, 3G, 4G, 5G, or wireless access point, etc.; the native language identifier and the target language identifier correspond to a native language preset in the mobile terminal 20 and a target language to be translated.
The mobile terminal 20 encodes the translated result by a predetermined encoding algorithm, the translator decodes the translated data by a predetermined decoding algorithm, the encoding is a process of converting information from one format or format to another format, also called a code of a computer programming language, which is called encoding for short, and the decoding is a reverse process of the encoding by encoding characters, numbers or other objects into digital codes by a predetermined method or converting information and data into a predetermined electric pulse signal.
In some embodiments, the mobile terminal 20 encodes the translation result to obtain translation data, including: the mobile terminal 20 uses a first encoding format algorithm to perform pre-encoding processing on the native language characters to obtain pre-encoded native language characters; the mobile terminal 20 re-encodes the pre-encoded native language words using a second encoding format algorithm to obtain encoded native language words.
For example, when the native language is chinese, the first encoding format algorithm is an encoding format algorithm (e.g., GBK encoding format algorithm) corresponding to chinese to perform pre-encoding to obtain pre-encoded chinese characters, and the second encoding format algorithm may be a UTF-8 encoding format algorithm, which re-encodes the pre-encoded chinese characters to obtain encoded chinese characters.
Among them, the UTF-8 encoding is a widely used encoding which represents characters using variable length bytes, theoretically up to 6 bytes in length, and the UTF-8 encoding is compatible with ASCII (0-127), which aims to incorporate global languages into one unified encoding, and a plurality of languages are currently incorporated.
The coding format algorithm corresponding to the chinese language may be a GBK coding format algorithm, and certainly, in other cases, the GBK coding may also be a GB2312 coding format algorithm, where the GBK coding is an internal code extension specification based on the GB2312-80 standard, a double-byte coding scheme is used, 23940 code bits are totalized, 21886 chinese characters and graphic symbols are received in total, where 21003 chinese characters (including radicals and components) and 883 graphic symbols are received, and the GBK is completely compatible with the GB2312-80 standard.
The mobile terminal 20 performs coding processing on the translation result to obtain translation data, and further includes: the mobile terminal 20 uses a third encoding format algorithm to perform pre-encoding processing on the translated words to obtain pre-encoded translated words; the mobile terminal 20 re-encodes the pre-encoded translated words using a fourth encoding format algorithm to obtain encoded translated words.
For example, when the translated text is japanese text, the third encoding format algorithm is an encoding format algorithm (e.g., Shift-JIS encoding format algorithm) corresponding to japanese to perform pre-encoding to obtain pre-encoded japanese text, and the fourth encoding format algorithm may be a UTF-8 encoding format algorithm that re-encodes the pre-encoded japanese text to obtain encoded japanese text.
Among them, the Shift-JIS is a common code table for japanese computer systems, which can accommodate full-size and half-size latin letters, hiragana, katakana, symbols, and japanese kanji.
In some embodiments, the translator 10 decodes the translation data to display the decoded translation data, including: the translator 10 uses a first decoding format algorithm to perform pre-decoding processing on the encoded native language characters to obtain pre-decoded native language characters; the translator 10 re-decodes the pre-decoded native language words using a second decoding format algorithm to obtain decoded native language words.
As mentioned above, the native language is chinese, the mobile terminal 20 has performed two-step encoding on the chinese characters returned by the server 30, the chinese characters are pre-encoded using the GBK encoding format algorithm, and then the pre-encoded chinese characters are re-encoded using the UTF-8 encoding format algorithm to obtain encoded chinese characters, and decoding is used as an inverse process of encoding, it can be understood that the first decoding format algorithm is the UTF-8 decoding format algorithm for pre-decoding the encoded chinese characters; the second decoding format algorithm is a GBK decoding format algorithm and is used for re-decoding the pre-decoded Chinese characters.
The translator 10 decodes the translation data, displays the decoded translation data, and includes: the translator 10 uses a third decoding format algorithm to carry out pre-decoding processing on the encoded translated words to obtain pre-decoded translated words; the translator 10 performs re-decoding processing on the pre-decoded translated words using a fourth decoding format algorithm to obtain decoded translated words.
As described above, the characters are translated into japanese characters, the mobile terminal 20 has performed two-step encoding on the japanese characters returned by the server 30, the Shift-JIS encoding format algorithm is used to pre-encode the japanese characters, and then the UTF-8 encoding format algorithm is used to re-encode the japanese characters with the encoded japanese characters to obtain encoded japanese characters, it can be understood that encoding is an inverse process of decoding, and the third decoding format algorithm is a UTF-8 decoding format algorithm for pre-decoding the encoded japanese characters; the fourth decoding format algorithm is a Shift-JIS decoding format algorithm, and is used for re-decoding the pre-decoded japanese characters.
In some embodiments, the translation result further includes audio playing data or an audio playing address corresponding to the translated text; the mobile terminal 20 is configured to play the audio playing data or obtain and play the audio playing data according to the audio playing address; and/or the translator 10 is used for playing the audio playing data or acquiring and playing the audio playing data according to the audio playing address.
Under a certain condition, the native language words, the translated words, the audio playing data or the audio playing address are returned to the mobile terminal 20 from the server 30 as a translation result, when the audio playing data needs to be played through the mobile terminal 20, the mobile terminal 20 processes the audio playing data and then plays the audio playing data through an audio playing module thereof, or the mobile terminal 20 obtains the audio playing address through obtaining the audio playing address, which can be in two modes of starting transcoding completion message notification and API/SDK, obtaining the playing address through transcoding completed event notification and storing the playing address to the service end, and accessing the service end to obtain the stored playing address during playing, or obtaining the playing address in real time through calling the SDK/API and transmitting the playing address to the audio playing module for playing.
It can be understood that, when the target language to be translated is japanese, the audio playing data or the audio playing address corresponds to japanese characters, and the user can browse the content displayed on the translator 10 and the audio corresponding to japanese characters played on the mobile terminal 20, so that the user can obtain related information more easily, and the user experience is improved.
Of course, the user may also select to send the audio playing data or the audio playing address from the mobile terminal 20 to the translator 10, so that the translator 10 can display the corresponding text content and play the corresponding audio content.
An embodiment of the present invention provides a translation method, as shown in fig. 2, the method includes:
s201: acquiring voice data to be translated;
the translator collects voice data of the user through a voice collection module such as a microphone, and the voice data can be formed by sending out voice data from any one of two parties of a conversation.
S202: sending the voice data to a mobile terminal so that the mobile terminal encapsulates the voice data, the native language identifier and the target language identifier into a translation request and sends the translation request to a server;
in this embodiment, the native language identifier and the target language identifier are used to indicate which language the voice data belongs to and which language the voice data is to be translated into, for example, when the native language identifier is a chinese identifier and the target language identifier is a japanese identifier, it can be determined that the voice data corresponds to chinese and the voice data needs to be translated into japanese.
S203: acquiring translation data sent by the mobile terminal;
the translation data is obtained by coding a translation result by the mobile terminal, the translation result comprises native language characters and translation characters, wherein the native language characters are obtained by converting voice data into characters corresponding to native language identifications by the server, and the translation characters are obtained by translating the voice data into the characters corresponding to target language identifications by the server.
S204: decoding the translation data to obtain the native language characters and the translation characters;
it should be noted that, because the translation result is transmitted between the mobile terminal and the translator, when the translation result is sent from the mobile terminal to the translator, the mobile terminal is required to encode the translation result to obtain translation data, and then the translator decodes the translation data to obtain decoded translation data, i.e. the native language words and the translation words.
S205: and displaying the native language characters and the translated characters.
The translation machine displays the native language characters and the translated characters through the display module, and on the display interface, the translated characters can be arranged on the upper half portion of the display interface and the native language characters can be arranged on the lower half portion of the display interface in order to facilitate a user to browse required contents.
In some embodiments, S204 specifically includes the following steps:
s2041: pre-decoding the encoded native language characters by using a first decoding format algorithm to obtain pre-decoded native language characters;
the first decoding format algorithm may be a general-purpose language decoding format algorithm, such as a UTF-8 decoding format algorithm.
S2042: using a second decoding format algorithm to perform re-decoding processing on the pre-decoded native language characters to obtain decoded native language characters;
the second decoding format algorithm is a decoding format algorithm corresponding to the native language text, for example, when the native language text is a chinese text, the second decoding format algorithm may be a GBK decoding format algorithm.
S2043: predecoding the encoded translated words by using a third decoding format algorithm to obtain predecoded translated words;
the third decoding format algorithm may be a general language decoding format algorithm, such as the UTF-8 decoding format algorithm.
S2044: and using a fourth decoding format algorithm to carry out re-decoding processing on the pre-decoded translated words to obtain decoded translated words.
The fourth decoding format algorithm is a decoding format algorithm corresponding to the translated text, and for example, when the translated text is japanese text, the fourth decoding format algorithm may be a Shift-JIS decoding format algorithm.
In this embodiment, the two steps S2041 and S2042 and the two steps S2043 and S2044 are used to decode the encoded native language text and the encoded translated text, respectively, and the processing procedures may be performed simultaneously.
Another embodiment of the present invention further provides a translation method, as shown in fig. 3, the method including:
s301: receiving voice data to be translated sent by a translator;
s302: packaging the voice data, the native language identifier and the target language identifier into a translation request;
s303: sending the translation request to a server so that the server generates a translation result according to the translation request, wherein the translation result comprises native language characters and translation characters;
the server converts the voice data into characters corresponding to the native language identification to obtain the native language characters, and the server translates the voice data into the characters corresponding to the target language identification to obtain the translated characters.
S304: acquiring the translation result, and coding the translation result to obtain translation data;
s305: and sending the translation data to the translation machine so that the translation machine decodes the translation data and displays the decoded translation data.
In some embodiments, S304 specifically includes the following steps:
s3041: pre-coding the native language characters by using a first coding format algorithm to obtain pre-coded native language characters;
the first encoding format algorithm may be a common language encoding format algorithm, such as the UTF-8 encoding format algorithm.
S3042: recoding the pre-coded native language characters by using a second coding format algorithm to obtain coded native language characters;
the second encoding format algorithm is an encoding format algorithm corresponding to the native language text, for example, when the native language text is a chinese text, the second encoding format algorithm may be a GBK encoding format algorithm.
S3043: pre-coding the translated words by using a third coding format algorithm to obtain pre-coded translated words;
the third encoding format algorithm may be a common language encoding format algorithm, such as the UTF-8 encoding format algorithm.
S3044: recoding the pre-coded translated words by using a fourth coding format algorithm to obtain coded translated words;
the fourth encoding format algorithm is an encoding format algorithm corresponding to the translated text, and for example, when the translated text is japanese text, the fourth encoding format algorithm may be a Shift-JIS encoding format algorithm.
In this embodiment, the two steps S3041 and S3042 and the two steps S3043 and S3044 are used to encode the native language characters and the translated characters respectively, and the processes may be performed simultaneously.
To describe the method in the above embodiment of the present invention in more detail, the following description is made with reference to fig. 6, and fig. 6 is a timing chart of a translation method provided in the embodiment of the present invention.
Fig. 7 is a schematic structural diagram of a translation apparatus according to an embodiment of the present invention. As shown in fig. 7, the translating apparatus 70 includes a first obtaining module 701, a first sending module 702, a second obtaining module 703, a decoding module 704, and a displaying module 705. The first obtaining module 701 is configured to obtain voice data to be translated; the first sending module 702 is configured to send voice data to the mobile terminal, so that the mobile terminal encapsulates the voice data, the native language identifier, and the target language identifier into a translation request, and sends the translation request to the server; the second obtaining module 703 is configured to obtain translation data sent by the mobile terminal; the decoding module 704 is used for decoding the translation data to obtain native language characters and translation characters; the display module 705 is used for displaying the native language words and the translated words.
In this embodiment, the translation data is obtained by the mobile terminal encoding a translation result, where the translation result includes a native language word and a translated word, where the native language word is obtained by the server converting the voice data into a word corresponding to the native language identifier, and the translated word is obtained by the server translating the voice data into a word corresponding to the target language identifier.
Optionally, the decoding module 704 is specifically configured to: pre-decoding the encoded native language characters by using a first decoding format algorithm to obtain pre-decoded native language characters; using a second decoding format algorithm to perform re-decoding processing on the pre-decoded native language characters to obtain decoded native language characters; predecoding the encoded translated words by using a third decoding format algorithm to obtain predecoded translated words; and using a fourth decoding format algorithm to carry out re-decoding processing on the pre-decoded translated words to obtain decoded translated words.
Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. As shown in fig. 5, the electronic device 80 includes a receiving module 801, an encapsulating module 802, a second sending module 803, a third obtaining module 804, an encoding module 805, and a third sending module 806. The receiving module 801 is configured to receive voice data to be translated, which is sent by the translator; the encapsulation module 802 is used for encapsulating the voice data, the native language identifier and the target language identifier into a translation request; the second sending module 803 is configured to send the translation request to a server, so that the server generates a translation result according to the translation request; the third obtaining module 804 is configured to obtain the translation result; the encoding module 805 is configured to perform encoding processing on the translation result to obtain translation data; the third sending module 806 is configured to send the translation data to the translation engine, so that the translation engine decodes the translation data and displays the decoded translation data.
In this embodiment, the translation result includes native language words obtained by the server converting the voice data into words corresponding to the native language identifier, and translated words obtained by the server translating the voice data into words corresponding to the target language identifier.
Optionally, the encoding module 805 is specifically configured to: pre-coding the native language characters by using a first coding format algorithm to obtain pre-coded native language characters; recoding the pre-coded native language characters by using a second coding format algorithm to obtain coded native language characters; pre-coding the translated words by using a third coding format algorithm to obtain pre-coded translated words; and performing recoding processing on the pre-coded translated words by using a fourth coding format algorithm to obtain the coded translated words.
Fig. 9 is a schematic structural diagram of a translation machine according to an embodiment of the present invention. As shown in fig. 9, the translator includes a first wireless communication module 901, at least one processor 902, and a memory 903 communicatively coupled to the at least one processor 602. Fig. 9 illustrates an example of one processor 901.
The processor 902 is communicatively connected to the first wireless communication module 901, and the processor 902 and the memory 903 may be connected by a bus or other means, for example, a bus connection in fig. 9.
The memory 903 may include high-speed random access memory and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 903 may optionally include memory located remotely from the processor 902, which may be connected to the processor 902 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The memory 903 stores instructions executable by the processor 902, and the instructions are executed by the processor 902 to enable the processor 902 to perform steps S201 to S205 or steps S2041 to S2042.
An embodiment of the present invention provides a storage medium, which may be any nonvolatile computer storage medium, and the storage medium has executable instructions, where the executable instructions are suitable for a processor to load and execute the translation method in any method embodiment described above, for example, to execute steps S201 to S205 or steps S2041 to S2042, or steps S301 to S305 or steps S3041 to S2044, and may also implement functions of each module shown in fig. 7 or each module shown in fig. 8.
The above-described embodiments of the apparatus or device are merely illustrative, wherein the unit modules described as separate parts may or may not be physically separate, and the parts displayed as module units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network module units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a general hardware platform, and certainly can also be implemented by hardware. Based on such understanding, the above technical solutions substantially or contributing to the related art may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments.
Finally, it is to be understood that the present invention may be embodied in many different forms and is not limited to the embodiments described in the present specification, which are provided as additional limitations to the present disclosure, and which are provided for the purpose of providing a more thorough understanding of the present disclosure. In the light of the above, the above features are combined with each other and many other variations of the different aspects of the invention described above are considered to be within the scope of the present description; further, modifications and variations will occur to those skilled in the art in light of the foregoing description, and it is intended to cover all such modifications and variations as fall within the true spirit and scope of the invention as defined by the appended claims.