Data processing methods, apparatus, electronic devices and computer-readable storage media
By storing key-value pairs in the rule file in different storage areas in a preset order, a one-time loading is achieved, solving the problem of excessively long rule file loading time in existing technologies and improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WANGYIYOUDAO INFORMATION TECH BEIJING CO LTD
- Filing Date
- 2022-08-23
- Publication Date
- 2026-05-26
AI Technical Summary
In existing speech synthesis systems, the front-end system experiences excessively long delays when loading rule files, negatively impacting user experience.
After splitting the key-value pairs in the rule file, they are stored in different storage areas in a preset order, including file header, key-value offset, key and value. The correspondence between key and value is determined by the key-value offset, so as to achieve one-time loading.
The loading time of the rules file has been greatly reduced, the user waiting time has been shortened, and the user experience has been greatly improved.
Smart Images

Figure CN115373760B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of data processing, and more specifically, the embodiments of the present invention relate to a data processing method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] This section is intended to provide background or context for embodiments of the invention set forth in the claims. The description herein may include concepts that may be explored, but not necessarily concepts that have been previously conceived or explored. Therefore, unless otherwise stated, what is described in this section is not prior art for the purposes of this application's specification and claims, and is not acknowledged as prior art simply by virtue of its inclusion in this section.
[0003] As an important component of the field of artificial intelligence, TTS (Text-To-Speech) technology has achieved end-to-end synthesis with rich emotions after a long period of development. It can quickly synthesize multiple languages and is currently used in navigation, voice broadcasting, intelligent customer service and most voice interaction scenarios.
[0004] TTS technology is generally divided into two parts: a front-end system and a back-end system. The front-end system converts text into a phoneme sequence and marks the start and end times, frequency changes, and other information for each phoneme. The back-end system generates relatively accurate speech based on the phoneme sequence and the start and end times, frequency changes, and other information for each phoneme.
[0005] To improve the accuracy of speech synthesis, the front-end system needs to use rule files such as dictionary files, text normalization (TN) files, etc. Taking Chinese dictionaries as an example, in TTS technology, it is necessary not only to know the overall pinyin of the keywords, but also the pinyin of each individual character. This requires the use of a single-string to multi-string mapping container.
[0006] Typically, key-value pairs are written as strings to a rules file (e.g., the format of a Chinese dictionary). Figure 1 As shown in the diagram, during the actual application loading process, keywords are read into the standard library associative container as single strings, and values are read into the standard library sequential container as multiple strings.
[0007] The above method has little impact on user experience when there are few key-value pairs. However, in practical applications, in order to improve the accuracy of speech synthesis, dictionary files, lexicon files, and TN files contain hundreds of thousands or even more key-value pairs. This increases the reading time line by line, causing excessive user waiting time and affecting user experience. Summary of the Invention
[0008] The loading process of the rule files in the front-end system of a known speech synthesis system is characterized by excessively long user wait times, which is a very frustrating process.
[0009] Therefore, there is a great need for improved data processing methods, devices, electronic equipment, and computer-readable storage media to reduce the waiting delay during the loading process of rule files.
[0010] In this context, embodiments of the present invention are intended to provide a data processing method, apparatus, electronic device, and computer-readable storage medium.
[0011] In a first aspect of the present invention, a data processing method is provided, applied to a front-end system of a speech synthesis system, wherein the speech synthesis rules of the front-end system are represented in a keyword-value format. The method includes: loading a rule file; wherein the rule file is stored in a non-volatile storage medium; the rule file includes: a file header stored in a first storage area, key-value offsets stored in a second storage area in a preset order, keywords stored in a third storage area in the preset order, and values stored in a fourth storage area in the preset order; the file header is used in the loading process of the rule file, and the key-value offsets, keywords, and values are all loaded at once.
[0012] In one embodiment of the present invention, the loading process of the rule file includes: reading the key-value offset into an offset order container according to the file header; reading the keyword into a word order container according to the file header; and reading the value into a value order container according to the file header.
[0013] In another embodiment of the present invention, the file header includes: the total length of the effective file content, the key value offset start position, the length of the second storage area, the keyword start position, the length of the third storage area, and the value start position, wherein the second storage area, the third storage area, and the fourth storage area are sequentially distributed; the loading process of the rule file specifically includes: determining the location of the second storage area according to the key value offset start position and the length of the second storage area, and reading the key value offset stored in the second storage area into an offset order container; determining the location of the third storage area according to the keyword start position and the length of the third storage area, and reading the keyword stored in the third storage area into a word order container; determining the location of the fourth storage area according to the value start position and the total length of the effective file content, and reading the value stored in the fourth storage area into a value order container.
[0014] In another embodiment of the present invention, the process of obtaining the rule file is as follows: reading the key-value pairs in the original rule file in sequence; splitting each key-value pair according to a predetermined rule to obtain multiple strings after splitting; wherein, the first string after splitting is used as the keyword, and the remaining strings are used as the values corresponding to the keyword; arranging the keywords and values corresponding to all key-value pairs in the preset order; establishing an initial rule file, configuring the third storage area for the keywords corresponding to all key-value pairs arranged in the preset order, and configuring the fourth storage area for the values corresponding to all key-value pairs arranged in the preset order; generating the file header and the key-value offset, configuring the first storage area for the file header, and configuring the second storage area for the key-value offset, to obtain the rule file.
[0015] In another embodiment of the present invention, the method further includes: determining a corresponding keyword offset based on the keyword length obtained after separating each key-value pair; determining a corresponding value offset based on the value length obtained after separating each key-value pair; and correspondingly, arranging the keywords corresponding to all key-value pairs and the values corresponding to all key-value pairs according to the preset order, including: arranging the keywords and keyword offsets corresponding to all key-value pairs and the values and value offsets corresponding to all key-value pairs according to the preset order; wherein, the keywords and keyword offsets corresponding to each key-value pair are arranged as a whole and the keyword offset is... The shift is placed before the keyword, and the value and value offset corresponding to each key-value pair are arranged as a whole with the value offset placed before the value; an initial rule file is established to configure the third storage area for the keywords corresponding to all key-value pairs arranged in the preset order, and to configure the fourth storage area for the values corresponding to all key-value pairs arranged in the preset order, including: establishing an initial rule file to configure the third storage area for the keywords and keyword offsets corresponding to all key-value pairs arranged in the preset order, and to configure the fourth storage area for the values and value offsets corresponding to all key-value pairs arranged in the preset order.
[0016] In another embodiment of the present invention, some or all of the dictionary files, thesaurus files, and text regularization files in the front-end system are represented as the rule files.
[0017] In another embodiment of the present invention, the method further includes: acquiring text; searching for a target keyword corresponding to a character contained in the text in the character order container; searching for a target key value offset corresponding to the target keyword in the offset order container according to the subscript result of the target keyword, wherein the subscript result is used to characterize the arrangement order of the target keyword in the third storage area; and searching for a target value corresponding to the target key value offset in the value order container according to the target key value offset.
[0018] In another embodiment of the present invention, searching for a target keyword corresponding to a character contained in the text in the character order container includes: performing a binary search in the character order container to find the target keyword corresponding to a character contained in the text.
[0019] In another embodiment of the present invention, the speech synthesis system is applied in a portable scanning translation device, the portable scanning translation device including a non-volatile storage medium, and the loading process of the rule file is part of the initialization process of the portable scanning translation device.
[0020] In a second aspect of the present invention, a data processing apparatus is provided, applied to a front-end system of a speech synthesis system. The speech synthesis rules of the front-end system are represented in a keyword-value format. The apparatus includes: a loading unit for loading a rule file; wherein the rule file is stored in a non-volatile storage medium; the rule file includes: a file header stored in a first storage area, key-value offsets stored in a second storage area in a preset order, keywords stored in a third storage area in the preset order, and values stored in a fourth storage area in the preset order; the file header is used in the loading process of the rule file, and the key-value offsets, keywords, and values are all loaded at once.
[0021] In one embodiment of the present invention, the loading unit includes: a first reading subunit, configured to read the key value offset into an offset order container according to the file header; a second reading subunit, configured to read the keyword into a word order container according to the file header; and a third reading subunit, configured to read the value into a value order container according to the file header.
[0022] In another embodiment of the present invention, the file header includes: the total length of the file's valid content, the key value offset start position, the length of the second storage area, the keyword start position, the length of the third storage area, and the value start position, wherein the second storage area, the third storage area, and the fourth storage area are sequentially distributed; the first reading subunit is specifically used to determine the location of the second storage area based on the key value offset start position and the length of the second storage area, and read the key value offset stored in the second storage area into an offset order container; the second reading subunit is specifically used to determine the location of the third storage area based on the keyword start position and the length of the third storage area, and read the keyword stored in the third storage area into a word order container; the third reading subunit is specifically used to determine the location of the fourth storage area based on the value start position and the total length of the file's valid content, and read the value stored in the fourth storage area into a value order container.
[0023] In another embodiment of the present invention, the system further includes: a rule file acquisition unit, configured to sequentially read key-value pairs in an original rule file; split each key-value pair according to a predetermined rule to obtain multiple split strings; arrange the keywords corresponding to all key-value pairs and the values corresponding to all key-value pairs in a preset order; establish an initial rule file, configure the third storage area for the keywords corresponding to all key-value pairs arranged in the preset order, and configure the fourth storage area for the values corresponding to all key-value pairs arranged in the preset order; generate the file header and the key-value offset, configure the first storage area for the file header, and configure the second storage area for the key-value offset to obtain the rule file; wherein the first split string is used as the keyword, and the remaining strings are used as the values corresponding to the keyword.
[0024] In another embodiment of the present invention, the rule file acquisition unit is further configured to: determine the corresponding keyword offset based on the keyword length obtained after separating each key-value pair; determine the corresponding value offset based on the value length obtained after separating each key-value pair; and accordingly, arrange the keywords corresponding to all key-value pairs and the values corresponding to all key-value pairs according to the preset order, including: arranging the keywords and keyword offsets corresponding to all key-value pairs and the values and value offsets corresponding to all key-value pairs according to the preset order; wherein, the keywords and keyword offsets corresponding to each key-value pair are arranged as a whole. Furthermore, the keyword offset is located before the keyword, and the value and value offset corresponding to each key-value pair are arranged as a whole, with the value offset located before the value; an initial rule file is established to configure the third storage area for the keywords corresponding to all key-value pairs arranged in the preset order, and to configure the fourth storage area for the values corresponding to all key-value pairs arranged in the preset order, including: establishing an initial rule file, configuring the third storage area for the keywords and keyword offsets corresponding to all key-value pairs arranged in the preset order, and configuring the fourth storage area for the values and value offsets corresponding to all key-value pairs arranged in the preset order.
[0025] In another embodiment of the present invention, some or all of the dictionary files, thesaurus files, and text regularization files in the front-end system are represented as the rule files.
[0026] In another embodiment of the present invention, the invention further includes: a text acquisition unit for acquiring text; a first search unit for searching in the word order container for a target keyword corresponding to a word contained in the text; a second search unit for searching in the offset order container for a target key value offset corresponding to the target keyword according to the index result of the target keyword, the index result being used to characterize the arrangement order of the target keyword in the third storage area; and a third search unit for searching in the value order container for a target value corresponding to the target key value offset according to the target key value offset.
[0027] In another embodiment of the present invention, the first search unit is specifically used to perform a binary search in the word order container for a target keyword corresponding to the word contained in the text.
[0028] In another embodiment of the present invention, the speech synthesis system is applied in a portable scanning translation device, the portable scanning translation device including a non-volatile storage medium, and the loading process of the rule file is part of the initialization process of the portable scanning translation device.
[0029] In a third aspect of the present invention, an electronic device is provided, comprising: a processor; and a memory storing computer instructions for data processing, wherein when the computer instructions are executed by the processor, the electronic device causes the electronic device to perform the method described according to the foregoing and the following embodiments.
[0030] In a fourth aspect of the present invention, a computer-readable storage medium is provided, comprising program instructions for data processing, which, when executed by a processor, cause the methods described according to the foregoing and the following plurality of embodiments to be implemented.
[0031] According to the data processing method, apparatus, electronic device, and computer-readable storage medium of the present invention, the key-value offsets, keywords, and values in the rule file are stored in different storage areas in a preset order. The key-value offsets and the preset order determine the correspondence between keywords and values. Thus, during the loading process of the rule file, the key-value offsets, keywords, and values can all be read at once, resulting in short user waiting time and a good user experience. Attached Figure Description
[0032] The above and other objects, features, and advantages of exemplary embodiments of the present invention will become readily apparent from the following detailed description taken in conjunction with the accompanying drawings. Several embodiments of the invention are illustrated in the drawings by way of example and not limitation, wherein:
[0033] Figure 1 A schematic diagram of a Chinese dictionary in the front-end system of a speech synthesis system is shown.
[0034] Figure 2 A block diagram schematically illustrates an exemplary computing system 200 suitable for implementing embodiments of the present invention;
[0035] Figure 3 A block diagram of a speech synthesis system according to an embodiment of the present invention is shown schematically;
[0036] Figure 4 A flowchart illustrating a data processing method according to an embodiment of the present invention is shown schematically.
[0037] Figure 5 A schematic diagram illustrating a rule file storage method according to an embodiment of the present invention is shown.
[0038] Figure 6 A flowchart illustrating a rule file acquisition process according to an embodiment of the present invention is shown schematically.
[0039] Figure 7 A flowchart illustrating a process for obtaining values from text according to an embodiment of the present invention is shown schematically;
[0040] Figure 8 A block diagram of a data processing apparatus according to an embodiment of the present invention is shown schematically.
[0041] Figure 9 A block diagram of an electronic device according to an embodiment of the present invention is shown schematically.
[0042] In the accompanying drawings, the same or corresponding reference numerals indicate the same or corresponding parts. Detailed Implementation
[0043] The principles and spirit of the invention will now be described with reference to several exemplary embodiments. It should be understood that these embodiments are given merely to enable those skilled in the art to better understand and implement the invention, and are not intended to limit the scope of the invention in any way. Rather, these embodiments are provided to make this disclosure more thorough and complete, and to fully convey the scope of this disclosure to those skilled in the art.
[0044] Figure 2 A block diagram of an exemplary computing system 200 suitable for implementing embodiments of the present invention is shown. For example... Figure 2 As shown, the computing system 200 may include: a central processing unit (CPU) 201, random access memory (RAM) 202, read-only memory (ROM) 203, a system bus 204, a hard disk controller 205, a keyboard controller 206, a serial interface controller 207, a parallel interface controller 208, a display controller 209, a hard disk 210, a keyboard 211, a serial external device 212, a parallel external device 213, and a display 214. Among these devices, the CPU 201, RAM 202, ROM 203, hard disk controller 205, keyboard controller 206, serial controller 207, parallel controller 208, and display controller 209 are coupled to the system bus 204. The hard disk 210 is coupled to the hard disk controller 205, the keyboard 211 is coupled to the keyboard controller 206, the serial external device 212 is coupled to the serial interface controller 207, the parallel external device 213 is coupled to the parallel interface controller 208, and the display 214 is coupled to the display controller 209. It should be understood that... Figure 2 The structural block diagrams described are for illustrative purposes only and are not intended to limit the scope of the invention. In some cases, certain devices may be added or removed depending on the specific circumstances.
[0045] Those skilled in the art will recognize that embodiments of the present invention can be implemented as a system, method, or computer program product. Therefore, this disclosure can be specifically implemented as entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." Furthermore, in some embodiments, the present invention can also be implemented as a computer program product contained in one or more computer-readable media, which includes computer-readable program code.
[0046] Any combination of one or more computer-readable media may be used. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example,, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (not exhaustive) of a computer-readable storage medium may include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device.
[0047] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0048] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0049] Computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network (including a local area network (LAN) or a wide area network (WAN)), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0050] Embodiments of the present invention will now be described with reference to flowchart illustrations and block diagrams of apparatus (or systems) according to embodiments of the invention. It should be understood that each block of the flowchart and / or block diagram, and combinations of blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine that, when executed by the computer or other programmable data processing apparatus, creates means for implementing the functions / operations specified in the blocks of the flowchart and / or block diagram.
[0051] These computer program instructions may also be stored in a computer-readable medium that enables a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable medium produce a product comprising an instruction apparatus that implements the functions / operations specified in the boxes of a flowchart and / or block diagram.
[0052] Computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, such that the instructions that execute on the computer or other programmable apparatus can provide a process for implementing the functions / operations specified in the boxes of a flowchart and / or block diagram.
[0053] According to embodiments of the present invention, a data processing method, apparatus, electronic device, and computer-readable storage medium are provided. Furthermore, any number of elements in the accompanying drawings is for illustrative purposes only and not for limitation, and any naming is for distinction only and has no limiting meaning.
[0054] The principles and spirit of the present invention will be explained in detail below with reference to several representative embodiments. Invention Overview
[0056] The inventors have discovered that existing speech synthesis systems use various rule files in their front-end systems, such as dictionary files, text normalization (TN) files, etc., written as key-value pairs in string format, typically one key-value pair per line. During the initialization of the speech synthesis system, it is necessary to load or read these rule files. Specifically, the front-end system reads the key-value pairs from the corresponding rule file one line at a time. Since dictionary files, text normalization (TN) files, and other similar files contain hundreds of thousands or even more key-value pairs, the rule file reading time of existing methods is usually several seconds, resulting in excessive user waiting time and negatively impacting the user experience.
[0057] Based on this, the inventors discovered a new method for storing rule files. Specifically, key-value pairs are split, and the keywords and values in each key-value pair are stored in different storage areas of a non-volatile storage medium according to a preset order. The key-value offsets corresponding to each key-value pair are also stored in a separate storage area according to a preset order. In this way, the preset order maps keywords, values, and key-value offsets sequentially. For example, the Nth keyword stored sequentially corresponds to the Nth value and the Nth key-value offset stored sequentially. Simultaneously, the length of the value corresponding to the keyword is determined by the key-value offset, thus completely mapping keywords and values. Consequently, when loading the rule file, all keywords, all values, and all key-value offsets are read once in the preset order, completing the loading process. The number of rule file reads is reduced from hundreds of thousands to a limited number of times, significantly shortening the reading time, reducing user waiting time, and greatly improving the user experience.
[0058] After introducing the basic principles of the present invention, various non-limiting embodiments of the present invention will be described in detail below.
[0059] Application Scenarios Overview
[0060] First refer to Figure 3 This is a block diagram of a speech synthesis system 300 according to an exemplary embodiment of the present invention. The specific speech synthesis process is as follows: after text is input into the front-end system 301, the front-end system 301 converts the text into an intermediate result that guides the back-end system 302 to perform speech synthesis, and the back-end system 302 synthesizes speech based on the intermediate result.
[0061] In the process of converting text into intermediate results in the front-end system's 301 redirect, many steps are involved, such as distinguishing words with the same spelling but different pronunciations, handling abbreviations, and determining pause positions. Some of these steps are for text standardization; for example, the abbreviation processing requires text regularization, and the process of distinguishing polyphonic characters requires text conversion to factors. These require rule files such as dictionary files, lexicon files, and TN files.
[0062] However, before performing actual speech synthesis, the speech synthesis system 300 needs to be initialized. During this process, the front-end system 301 needs to load these rule files. The rule file loading process in the prior art takes a long time and results in a poor user experience.
[0063] Exemplary methods
[0064] The following is combined Figure 3 Application scenarios, refer to Figure 4 The following describes a data processing method 400 according to an exemplary embodiment of the present invention. It should be noted that the above application scenarios are shown only to facilitate understanding of the spirit and principles of the present invention, and the embodiments of the present invention are not limited in any way. Rather, the embodiments of the present invention can be applied to any applicable scenario.
[0065] Specifically, Figure 4 The data processing method 400 shown is applied to the front-end system 301 of the speech synthesis system 300. The speech synthesis rules of the front-end system 301 are represented in a keyword-value format; that is, the front-end system 301 should include a rule file representing keywords and values, and the correspondence between them. Figure 3 The data processing method shown is the process of loading the rule file during the 301 initialization of the front-end system. It should be noted that the 301 initialization process of the front-end system also involves other operations, which will not be elaborated here as they do not involve the substantive features of this embodiment.
[0066] Furthermore, in Figure 4 In the data processing method shown, the rule file in the front-end system includes: a file header stored in the first storage area, key-value offsets stored in the second storage area in a preset order, keywords stored in the third storage area in a preset order, and values stored in the fourth storage area in a preset order. The key-value offset corresponds to the length of the keyword value, or the number of values. The file header is used in the rule file loading process and can be understood as guidance information for the rule file, guiding the front-end system to load the rule file during the 301 initialization process.
[0067] In this rules file, keywords, values, and key-value offsets follow the same preset order, establishing a sequential correspondence between them. The key-value offset also determines the length of the value corresponding to the keyword. In practical applications, the preset order can be determined according to set rules, which typically sort based on a portion of the keyword or value. For example, a Chinese dictionary can use one of the following sorting methods: alphabetical order, radical order, or stroke order; an English dictionary can use alphabetical order, etc.
[0068] It should be noted that, according to convention, keywords and values are usually put together to form key-value pairs to match keywords and values. However, the rule file of this invention stores keywords and values separately. This storage method is equivalent to serializing the key-value pairs.
[0069] To facilitate a more intuitive understanding of the rule documents, in the following... Figure 5 Before explaining the rule file loading process of the data processing method shown, a specific embodiment will be used to illustrate the storage method of the rule file. (See [link to previous document]). Figure 5 This is an example of a rule file storage method, corresponding to a Chinese dictionary file. In Figure 5 The Chinese rule file is divided into a file header storage area (corresponding to the first storage area), a key value offset storage area (corresponding to the second storage area), a keyword storage area (corresponding to the third storage area), and a value storage area (corresponding to the fourth storage area).
[0070] Specifically, the file header storage area has a length of 32 (corresponding to an offset of 0-31), stores header information of length 8, and contains 6 integer type data, each of which occupies a length of 4. These 6 integer type data include: 113, representing the total length of the file's valid content; 32, representing the starting position of the offset of the key's value (also referred to as the key-value offset start position in this document); 12, representing the length of the offset of the key's value (also referred to as the second storage area length in this document); 44, representing the starting position of the key; 20, representing the length of the key storage area (also referred to as the third storage area length in this document); and 64, representing the starting position of the value.
[0071] Specifically, the keyword storage area has a length of 20, with a corresponding offset of 44 - 63, and stores all the keywords in the Chinese dictionary. The numbers in this part represent the offset of each keyword in this storage area. Based on this offset, the keyword length of each keyword can be determined. For example, taking the offset of each Chinese character in a keyword as 1 for illustration, 2 is used to represent that the offset of the first keyword "一个" in the keyword storage area is 0 - 1. Assuming there is no such offset and all keywords are in this area, it would be impossible to distinguish whether the first keyword is "一", "一个", or "一个一", etc. The keyword storage area is used to store all the keywords. In practical applications, the keyword storage area corresponds to a keyword container.
[0072] The value storage area has a length of 49, with a corresponding offset of 64 - 112, and stores all the values in the Chinese dictionary. The numbers before this part represent the offset of each value in this storage area. Based on this offset, the value length of each value can be determined. For example, 3 is used to represent that the offset of the first value "yi2" in the value storage area is 0 - 2. Assuming there is no such offset and all values are in this area, it would be impossible to distinguish whether the first value is "y", "yi", or "yi2", etc. It should be noted that each value includes a pinyin part and a tone part. The first number after the pinyin represents the tone of this pinyin. For example, the "2" in the first value "yi2" represents the second tone, and the number before each value represents the offset of this value in this storage area. Obviously, the "number before each value" does not include the tone part of the previous value. This part is used to restore the value of each keyword according to the serialization result of the values.
[0073] In addition, for the Chinese dictionary, each keyword corresponds to multiple Chinese characters, and correspondingly, each keyword corresponds to the pinyin of multiple Chinese characters, and thus corresponds to multiple values. In this way, the keyword corresponding to each key - value pair is stored as a single string, and the value corresponding to each key - value pair is stored in a multi - string form. Among them, each keyword in the Chinese dictionary corresponds to the key in each key - value pair.
[0074] The key - value offset storage area has a length of 12, with a corresponding offset of 32 - 43, and stores the offset of the value corresponding to the keyword in the Chinese dictionary (corresponding key - value offset). For example, 2 is used to represent that the keyword "一个" corresponds to 2 values, value 0 and value 1. Among them, value 0 is yi2, and value 2 is ge4. Assuming there is no such value, after finding the keyword "一个", it would be impossible to know which values the keyword corresponds to, and it would be impossible to know whether the pinyin corresponding to "一个" is "yi2" or "yi2 ge4" or "yi2 ge4yi2", etc.
[0075] In this way, the key-value offsets stored in the key-value offset memory, the keywords stored in the keyword storage area, and the values stored in the value storage area are completely matched, realizing the mapping from keywords to values. In terms of presentation, it realizes the mapping from a single string to multiple strings.
[0076] It should be noted that, Figure 5 In the rule file, the key-value offset storage area, keyword storage area, and value storage area are stored in a structured manner in the same file, that is, the rule file is stored as a whole. However, in practical applications, the different storage areas can also be stored as separate files. In this case, the three files corresponding to the three storage areas are read from the beginning. Therefore, the file header storage area does not need the key-value offset start position, the length of the second storage area, the start position of the keyword, the length of the third storage area, and the start position of the value. Only the total length of the effective content of the file is needed.
[0077] It should also be noted that, Figure 5 Each offset in the code represents the overall order of the keys and values in their respective storage areas. However, in practical applications, each offset can also represent the length of each key and value. For example, the three numbers in the key-value offset storage area can be replaced with 2, 3, and 3, representing that the first key "one" corresponds to 2 values, the second key "one by one" corresponds to 3 values, and the third key "one person" corresponds to 3 values. When calculating the overall offset, the numbers can be added together. Additionally, in other embodiments... Figure 5 The total length of the valid content in the file can also be replaced with the length of the fourth storage area to obtain the length of the value storage area. Figure 5 The data type in can also be other data types besides int, such as long, short, etc.
[0078] also, Figure 5The illustrated embodiment uses a Chinese dictionary as an example, but the speech synthesis system is not limited to Chinese and can be applied to other languages. Here, English is used as an example, generally with English words and sentences as keywords and phonetic symbols as values. For example, for the English key-value pair "Chinese and Maths ch ay niy0 z ah ndm ae th s", the keyword is "Chinese and Maths", and the value is "ch ay n iy0 z ah n dm ae th s". For English keywords and values, each letter, space, number, etc., corresponds to an offset, such as the letter "C" corresponding to an offset, and each phonetic symbol corresponds to a key-value offset, such as "ch". Therefore, the offset of the keyword "Chinese and Maths" is 17, the offset of the value "ch ay n iy0 z ah ndm ae th s" is 30, and the key-value offset is 12.
[0079] In practical applications, the rule file is stored in non-volatile storage media and loaded into memory during the front-end system's 301 initialization process. See [link to details] for the loading process. Figure 4 As shown:
[0080] In step S401, the key-value offset stored in the second storage area is read into the offset order container.
[0081] Specifically, the key-value offsets stored in the second storage area can be read into the offset order container according to a preset order based on the file header. If the file header includes the start position of the key-value offset and the length of the second storage area, the location of the second storage area can be determined based on the start position of the key-value offset and the length of the second storage area, and the key-value offsets stored in the second storage area can be read into the offset order container.
[0082] It is understood that in other exemplary embodiments, the address of the second storage area may also be stored, and the key-value offset of the second storage area may be read into the offset order container based on that address. In some other exemplary embodiments, if the storage area containing the key-value offset is the last storage area in the rule file, the key-value offset of the second storage area may also be read into the offset order container based on the start position of the key-value offset and the total length of the valid content of the file.
[0083] In step S402, the keywords stored in the third storage area are read into the word order container.
[0084] Specifically, keywords stored in the third storage area can be read into the word order container in a preset order based on the file header. If the file header includes the keyword start position and the length of the third storage area, the location of the third storage area can be determined based on the keyword start position and the length of the third storage area, and the keywords stored in the third storage area can be read into the word order container.
[0085] It is understood that in other exemplary embodiments, the address of the third storage area may also be stored, and the word-to-word order container of the third storage area may be read based on that address. In other exemplary embodiments, if the storage area containing the keyword is the last storage area in the rule file, the keyword in the third storage area may also be read into the word order container based on the keyword's starting position and the total length of the file's valid content.
[0086] In step S403, the value stored in the fourth storage area is read into the value order container.
[0087] Specifically, the values stored in the fourth storage area can be read into the value order container in a preset order based on the file header. If the file header includes the value start position and the total length of the valid file content, and the fourth storage area is the last storage area in the rule file, the location of the fourth storage area can be determined based on the value start position and the total length of the valid file content, and the values stored in the fourth storage area can be read into the value order container.
[0088] It is understood that in other exemplary embodiments, the address of a fourth storage area may also be stored, and the value of the fourth storage area may be read into a value sequence container based on that address.
[0089] It should be noted that since the key-value offset, keywords, and values are all stored in the corresponding storage area in a preset order, the key-value offset, keywords, and values are all read in one go; that is, a rule file can be loaded in just three reads. Compared with existing methods that require hundreds of thousands or more reads to load, the loading time is greatly shortened, user waiting time is reduced, and the user experience is improved. At the same time, the three sequential containers only store serialized content, effectively reducing the amount of physical memory required. The inventors applied the technical solution of this invention to a specific speech synthesis system, reducing the initialization time of the front-end system 301 from 3.3 seconds to 0.3 seconds. Physical memory usage was reduced by approximately 27MB.
[0090] In addition, it should be noted that, see Figure 5 As shown, the second, third, and fourth storage areas are arranged in sequence, but the present invention is not limited thereto. In other exemplary embodiments, the three storage areas may be in other orders, such as the third and fourth storage areas being located before the second storage area.
[0091] Considering that language will become richer with social development and other factors, in an exemplary embodiment of the present invention, the length of the second storage area is greater than the space occupied by the key-value offset, and the length of the third storage area is greater than the space occupied by the keyword. This reserves storage space for newly emerging keywords and values, facilitating the updating of the rule file.
[0092] In actual development, considering the huge number of keywords and values, in an exemplary embodiment of the present invention, the rule file in the embodiment of the present invention can be generated using existing rule files.
[0093] Specifically, see Figure 6 As shown, a flowchart 600 of a rule file acquisition process provided for an exemplary embodiment of the present invention includes:
[0094] In step S601, the key-value pairs in the original rule file are read sequentially.
[0095] The original rule file is the rule file used in existing technologies.
[0096] In step S602, each key-value pair is split according to a predetermined rule to obtain multiple split strings.
[0097] Specifically, key-value pairs in the initial rule file can be read line by line, then split by spaces. The first string after each split is used as the key, and the remaining strings are used as the values corresponding to the keys. Understandably, it's possible to read two or more lines at a time, but reading line by line makes the key-value pairing clear and simple, and the subsequent key-value offsets are also easier to obtain.
[0098] In step S603, the keywords corresponding to all key-value pairs and the values corresponding to all key-value pairs are arranged in a preset order.
[0099] Specifically, since the key-value pairs in the initial rule file are sorted according to the set rules, the sorting of the key-value pairs can be directly used as the preset order.
[0100] In step S604, an initial rule file is established, a third storage area is configured for the keywords corresponding to all key-value pairs arranged in a preset order, and a fourth storage area is configured for the values corresponding to all key-value pairs arranged in a preset order.
[0101] In step S605, a file header and key-value offset are generated, and a first storage area is configured for the file header and a second storage area is configured for the key-value offset to obtain the rule file.
[0102] Specifically, after sorting the keywords and values in a preset order, the length of the third storage area corresponding to the keywords and the length of the fourth storage area corresponding to the values can be obtained. Simultaneously, based on the correspondence between keywords and values in the key-value pairs, the key-value offset of each key-value pair can be calculated, and the length of the second storage area corresponding to the key-value offset can be obtained. This allows the creation of a file header that includes the total length of the file's valid content. Thus, after establishing an initial rule file, corresponding storage areas can be configured for the file header, key-value offsets, keywords, and values to obtain the rule file itself. This achieves the serialization and saving of information such as keywords, values, and key-value offsets into the rule file.
[0103] As mentioned earlier, each storage area in the rule file can be multiple files or a single file. The content of the file header will also be different depending on the number of rule files. For details, please refer to the previous description of the file header, which will not be repeated here.
[0104] pass Figure 6 The embodiment shown uses the original rule file to obtain the rule file required by the present invention, which greatly reduces the workload of obtaining the rule file and avoids human errors that may occur during the process of obtaining the rule file.
[0105] Referring to the foregoing, in practical applications, it is often necessary to obtain the offsets corresponding to keywords and values in order to identify different keywords and values. Therefore, in an exemplary embodiment of the present invention, in... Figure 6 Based on the illustrated embodiment, it may further include: determining the corresponding key offset by the key length obtained after separating each key-value pair; and determining the corresponding value offset by the value length obtained after separating each key-value pair.
[0106] Understandably, in practical use, the keyword length can be directly used as the keyword offset and the value length as the value offset. Alternatively, when obtaining the keyword length of a keyword, the lengths of all previous keywords can be summed and the summed result can be used as the keyword offset. When obtaining the value length of a value, the lengths of all previous values can be summed and the summed result can be used as the value offset.
[0107] Accordingly, when sorting and storing keywords and values, the keyword offsets and value offsets are simultaneously sorted and stored. Specifically, the keyword and keyword offset for each key-value pair are arranged as a whole, with the keyword offset preceding the keyword; similarly, the value and value offset for each key-value pair are arranged as a whole, with the value offset preceding the value. For a more intuitive understanding, see [link to documentation]. Figure 5 The key storage method and value storage method are shown.
[0108] It should be noted that the technical solution of this embodiment can be applied to some or all of the dictionary files, thesaurus files, and text regularization files in the front-end system 301. When all the dictionary files, thesaurus files, and text regularization files in the front-end system 301 are represented as rule files in this embodiment, it can save more user waiting time and reduce physical memory.
[0109] Furthermore, this section explains the usage process after the rules file is loaded. See [link / reference] Figure 7 As shown, a flowchart 700 of a process for obtaining values from text is provided in an exemplary embodiment of the present invention, including:
[0110] In step S701, text is obtained.
[0111] This text is the text that the speech synthesis system will synthesize.
[0112] In step S702, the target keyword corresponding to the word contained in the text is searched in the word order container.
[0113] In one exemplary embodiment, a binary search can be used within the word order container to find the target keyword corresponding to the words contained in the text, thereby finding the target keyword more quickly. It is understood that in other embodiments, other search methods, such as sequential search, can also be used to find the target keyword corresponding to the words contained in the text.
[0114] In step S703, the target key value offset corresponding to the target key is searched in the offset order container according to the subscript result of the target key.
[0115] Specifically, the subscript result is used to characterize the order of the target key in the third storage area. Due to the inherent characteristics of the sequential container, when storing the key, value, and key-value offset in the corresponding sequential container, subscript results representing the order of arrangement are assigned to the key, value, and key-value offset. Therefore, the subscript result can be used to find the target key-value offset corresponding to the target key in the offset sequential container.
[0116] In step S704, the target value corresponding to the target key value offset is searched in the value order container according to the target key value offset.
[0117] Specifically, the target key offset can be used to determine which values in the value order container the target key corresponds to, and these values are the target values.
[0118] Furthermore, in an exemplary embodiment of the present invention, the speech synthesis system is applied to a portable scanning translation device. The portable scanning translation device includes a non-volatile storage medium, and the loading process of the rule file is part of the initialization process of the portable scanning translation device. In practical use, the portable scanning translation device can be a dictionary pen, a translator, etc. Because portable scanning translation devices have small memory and relatively low computing power, applying the technical solution of the present invention to portable scanning translation devices will significantly shorten their initialization time and greatly improve the user experience.
[0119] Exemplary device
[0120] After introducing the data processing method according to exemplary embodiments of the present invention, the following will refer to... Figure 8 A data processing apparatus 800 according to an exemplary embodiment of the present invention will be described. Figure 8 The data processing device shown is applied to the front-end system 301 of the speech synthesis system 300. The speech synthesis rules of the front-end system 301 are represented in the keyword-value format. The data processing device 800 includes a loading unit 801.
[0121] The loading unit 801 is used to load a rule file; wherein the rule file is stored in a non-volatile storage medium; the rule file includes: a file header stored in the first storage area, key-value offsets stored in the second storage area in a preset order, keywords stored in the third storage area in a preset order, and values stored in the fourth storage area in a preset order; the file header is used in the loading process of the rule file, and the key-value offsets, keywords, and values are all loaded at once.
[0122] In one embodiment of the present invention, the loading unit 801 includes: a first reading subunit, configured to read the key value offset into an offset order container according to the file header; a second reading subunit, configured to read the keyword into a word order container according to the file header; and a third reading subunit, configured to read the value into a value order container according to the file header.
[0123] In another embodiment of the present invention, the file header includes: the total length of the effective file content, the key value offset start position, the length of the second storage area, the keyword start position, the length of the third storage area, and the value start position, wherein the second storage area, the third storage area, and the fourth storage area are sequentially distributed; the first reading subunit is specifically used to determine the location of the second storage area based on the key value offset start position and the length of the second storage area, and read the key value offset stored in the second storage area into the offset order container; the second reading subunit is specifically used to determine the location of the third storage area based on the keyword start position and the length of the third storage area, and read the keyword stored in the third storage area into the word order container; the third reading subunit is specifically used to determine the location of the fourth storage area based on the value start position and the total length of the effective file content, and read the value stored in the fourth storage area into the value order container.
[0124] In another embodiment of the present invention, the system further includes: a rule file acquisition unit, configured to sequentially read key-value pairs in an original rule file; split each key-value pair according to a predetermined rule to obtain multiple split strings; arrange the keywords corresponding to all key-value pairs and the values corresponding to all key-value pairs in a preset order; establish an initial rule file, configure a third storage area for the keywords corresponding to all key-value pairs arranged in the preset order, and configure a fourth storage area for the values corresponding to all key-value pairs arranged in the preset order; generate a file header and key-value offsets, configure a first storage area for the file header, and configure a second storage area for the key-value offsets to obtain a rule file; wherein the first split string is used as the keyword, and the remaining strings are used as the values corresponding to the keyword.
[0125] In another embodiment of the present invention, the rule file acquisition unit is further configured to: determine the corresponding keyword offset based on the keyword length obtained after separating each key-value pair; determine the corresponding value offset based on the value length obtained after separating each key-value pair; accordingly, arrange the keywords corresponding to all key-value pairs and the values corresponding to all key-value pairs in a preset order, including: arranging the keywords and keyword offsets corresponding to all key-value pairs and the values and value offsets corresponding to all key-value pairs in a preset order; wherein, the keywords and keyword offsets corresponding to each key-value pair are arranged as a whole and the keyword offset is placed before the keyword, and the values and value offsets corresponding to each key-value pair are arranged as a whole and the value offset is placed before the value; establish an initial rule file, configure a third storage area for the keywords corresponding to all key-value pairs arranged in the preset order, and configure a fourth storage area for the values corresponding to all key-value pairs arranged in the preset order, including: establishing an initial rule file, configuring a third storage area for the keywords and keyword offsets corresponding to all key-value pairs arranged in the preset order, and configuring a fourth storage area for the values and value offsets corresponding to all key-value pairs arranged in the preset order.
[0126] In another embodiment of the present invention, some or all of the dictionary files, thesaurus files, and text regularization files in the front-end system are represented as rule files.
[0127] In another embodiment of the present invention, the invention further includes: a text acquisition unit for acquiring text; a first search unit for searching in a word order container for a target keyword corresponding to a word contained in the text; a second search unit for searching in an offset order container for a target key value offset corresponding to the target keyword based on the subscript result of the target keyword, the subscript result being used to characterize the arrangement order of the target keyword in the third storage area; and a third search unit for searching in a value order container for a target value corresponding to the target key value offset based on the target key value offset.
[0128] In another embodiment of the present invention, the first search unit is specifically used to perform a binary search in the word order container for the target keyword corresponding to the word contained in the text.
[0129] In another embodiment of the invention, the speech synthesis system is applied in a portable scanning translation device, which includes a non-volatile storage medium, and the loading process of the rule file is part of the initialization process of the portable scanning translation device.
[0130] Next, refer to Figure 9 An electronic device according to an exemplary embodiment of the present invention will be described.
[0131] Figure 9 A block diagram of an electronic device 900 according to an embodiment of the present invention is shown schematically. For example... Figure 9 As shown, the electronic device 900 may include a processor 901 and a memory 902. The memory 902 stores computer instructions for data processing. When these computer instructions are executed by the processor 901, the electronic device 900 performs the methods described in any of the preceding method embodiments. For example, in some embodiments, the electronic device 900 may perform actions such as loading rule files. Based on this, the electronic device 900 can reduce user waiting time and greatly improve the user experience.
[0132] In some implementation scenarios, electronic device 900 may include devices with information display and processing functions (such as tablets, mobile phones or other smart learning devices). The present invention does not limit the structural design that electronic device 900 may have.
[0133] It should be noted that although several devices or sub-devices of the device have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of the invention, the features and functions of two or more devices described above can be embodied in one device. Conversely, the features and functions of one device described above can be further divided and embodied by multiple devices.
[0134] Furthermore, although the operations of the method of the present invention are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all of the operations shown must be performed to achieve the desired result. Rather, the steps depicted in the flowchart may be performed in a different order. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0135] The use of the verbs "including" and "contains" and their inflections in the application documents does not preclude the existence of elements or steps other than those described in the application documents. The article "a" or "one" preceding an element does not preclude the existence of multiple such elements.
[0136] While the spirit and principles of the invention have been described with reference to several specific embodiments, it should be understood that the invention is not limited to the disclosed specific embodiments, and the division of aspects does not imply that features in these aspects cannot be combined for benefit; such division is merely for ease of description. The invention is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims. The scope of the appended claims is to be interpreted in the broadest sense, thereby encompassing all such modifications and equivalent structures and functions.
[0137] The acquisition, storage, and application of user personal information involved in the technical solution disclosed herein comply with relevant laws and regulations and do not violate public order and good morals.
Claims
1. A data processing method, characterized in that, A front-end system applied to a speech synthesis system, wherein the speech synthesis rules of the front-end system are represented in a keyword-value format, and the method includes: Load the rules file; The rule file is stored in a non-volatile storage medium. The rule file includes: a file header stored in the first storage area, key-value offsets stored in the second storage area in a preset order, keywords stored in the third storage area in the preset order, and values stored in the fourth storage area in the preset order; The file header is used in the loading process of the rule file, and the key-value offset, the keyword, and the value are all loaded at once. Here, the keyword-value pair is split to obtain the keyword and the value; the key-value offset corresponds to the length of the keyword value.
2. The method according to claim 1, characterized in that, The loading process of the rule file includes: The key-value offset is read into the offset order container based on the file header; The keywords are read into a word order container based on the file header; The value is read into the value order container based on the file header.
3. The method according to claim 2, characterized in that, The file header includes: the total length of the effective content of the file, the key value offset start position, the length of the second storage area, the keyword start position, the length of the third storage area, and the value start position, wherein the second storage area, the third storage area, and the fourth storage area are distributed in sequence; The loading process of the rule file specifically includes: The location of the second storage area is determined based on the key value offset start position and the length of the second storage area, and the key value offset stored in the second storage area is read into the offset order container. The location of the third storage area is determined based on the start position of the keyword and the length of the third storage area, and the keyword stored in the third storage area is read into the word order container. The location of the fourth storage area is determined based on the starting position of the value and the total length of the valid content of the file, and the value stored in the fourth storage area is read into the value order container.
4. The method according to any one of claims 1 to 3, characterized in that, The process of obtaining the rule file is as follows: Read the key-value pairs from the original rule file sequentially; Each key-value pair is split according to a predetermined rule to obtain multiple split strings; In this case, the first string after separation is used as the key, and the remaining strings are used as the values corresponding to the key; Arrange the keywords corresponding to all the key-value pairs and the values corresponding to all the key-value pairs in the preset order respectively; An initial rule file is established, and the third storage area is configured for the keywords corresponding to all the key-value pairs arranged in the preset order, and the fourth storage area is configured for the values corresponding to all the key-value pairs arranged in the preset order. Generate the file header and the key-value offset, configure the first storage area for the file header, and configure the second storage area for the key-value offset to obtain the rule file.
5. The method according to claim 4, characterized in that, Also includes: The keyword offset is determined by the length of the keyword obtained after splitting each key-value pair; The value offset is determined by the length of the value obtained after splitting each key-value pair; Accordingly, the keywords corresponding to all the key-value pairs and the values corresponding to all the key-value pairs are arranged in the preset order, including: All the keywords and keyword offsets corresponding to the key-value pairs and all the values and value offsets corresponding to the key-value pairs are arranged in the preset order; wherein, the keywords and keyword offsets corresponding to each key-value pair are arranged as a whole with the keyword offset preceding the keyword, and the values and value offsets corresponding to each key-value pair are arranged as a whole with the value offset preceding the value; Establish an initial rule file, configure the third storage area for the keywords corresponding to all key-value pairs arranged in the preset order, and configure the fourth storage area for the values corresponding to all key-value pairs arranged in the preset order, including: An initial rule file is established, and the third storage area is configured for the keywords and keyword offsets corresponding to all the key-value pairs arranged in the preset order, and the fourth storage area is configured for the values and value offsets corresponding to all the key-value pairs arranged in the preset order.
6. The method according to any one of claims 1 to 3, characterized in that, The rule file is represented by some or all of the dictionary files, thesaurus files, and text regularization files in the front-end system.
7. The method according to any one of claims 2 to 3, characterized in that, Also includes: Get the text; Search the word order container for the target keyword that corresponds to the word contained in the text; Based on the index result of the target keyword, the target key value offset corresponding to the target keyword is found in the offset order container. The index result is used to characterize the arrangement order of the target keyword in the third storage area. Based on the target key value offset, search for the target value corresponding to the target key value offset in the value order container.
8. The method according to claim 7, characterized in that, Searching for target keywords corresponding to the characters contained in the text within the character order container includes: A binary search is performed in the word order container to find the target keyword corresponding to the word contained in the text.
9. The method according to any one of claims 1 to 3, characterized in that, The speech synthesis system is used in a portable scanning translation device, which includes a non-volatile storage medium, and the loading process of the rule file is part of the initialization process of the portable scanning translation device.
10. A data processing apparatus, characterized in that, A front-end system for a speech synthesis system, wherein the speech synthesis rules of the front-end system are represented in a keyword-value format, and the device includes: The loading unit is used to load rule files; The rule file is stored in a non-volatile storage medium. The rule file includes: a file header stored in the first storage area, key-value offsets stored in the second storage area in a preset order, keywords stored in the third storage area in the preset order, and values stored in the fourth storage area in the preset order; The file header is used in the loading process of the rule file, and the key-value offset, the keyword, and the value are all loaded at once. Here, the keyword-value pair is split to obtain the keyword and the value; the key-value offset corresponds to the length of the keyword value.
11. The apparatus according to claim 10, characterized in that, The loading unit includes: The first reading subunit is used to read the key value offset into the offset order container according to the file header; The second reading subunit is used to read the keyword into the word order container according to the file header; The third reading subunit is used to read the value into the value order container according to the file header.
12. The apparatus according to claim 11, characterized in that, The file header includes: the total length of the effective content of the file, the key value offset start position, the length of the second storage area, the keyword start position, the length of the third storage area, and the value start position, wherein the second storage area, the third storage area, and the fourth storage area are distributed in sequence; The first reading subunit is specifically used to determine the location of the second storage area based on the key value offset start position and the length of the second storage area, and read the key value offset stored in the second storage area into the offset order container; The second reading subunit is specifically used to determine the location of the third storage area based on the start position of the keyword and the length of the third storage area, and to read the keyword stored in the third storage area into the word order container; The third reading subunit is specifically used to determine the location of the fourth storage area based on the starting position of the value and the total length of the effective content of the file, and to read the value stored in the fourth storage area into the value order container.
13. The apparatus according to any one of claims 10 to 12, characterized in that, The device further includes: A rule file acquisition unit is used to sequentially read key-value pairs from an original rule file; split each key-value pair according to a predetermined rule to obtain multiple strings after splitting; arrange the keywords corresponding to all key-value pairs and the values corresponding to all key-value pairs in a preset order; establish an initial rule file, configure the third storage area for the keywords corresponding to all key-value pairs arranged in the preset order, and configure the fourth storage area for the values corresponding to all key-value pairs arranged in the preset order; generate the file header and the key-value offset, configure the first storage area for the file header, and configure the second storage area for the key-value offset to obtain the rule file; wherein, the first string after splitting is used as the keyword, and the remaining strings are used as the values corresponding to the keyword.
14. The apparatus according to claim 13, characterized in that, The rule file acquisition unit is also used for: The keyword offset is determined by the length of the keyword obtained after splitting each key-value pair; The value offset is determined by the length of the value obtained after splitting each key-value pair; Accordingly, the keywords corresponding to all the key-value pairs and the values corresponding to all the key-value pairs are arranged in the preset order, including: All the keywords and keyword offsets corresponding to the key-value pairs and all the values and value offsets corresponding to the key-value pairs are arranged in the preset order; wherein, the keywords and keyword offsets corresponding to each key-value pair are arranged as a whole with the keyword offset preceding the keyword, and the values and value offsets corresponding to each key-value pair are arranged as a whole with the value offset preceding the value; Establish an initial rule file, configure the third storage area for the keywords corresponding to all key-value pairs arranged in the preset order, and configure the fourth storage area for the values corresponding to all key-value pairs arranged in the preset order, including: An initial rule file is established, and the third storage area is configured for the keywords and keyword offsets corresponding to all the key-value pairs arranged in the preset order, and the fourth storage area is configured for the values and value offsets corresponding to all the key-value pairs arranged in the preset order.
15. The apparatus according to any one of claims 10 to 12, characterized in that, The rule file is represented by some or all of the dictionary files, thesaurus files, and text regularization files in the front-end system.
16. The apparatus according to any one of claims 11 to 12, characterized in that, Also includes: The text acquisition unit is used to acquire text. The first search unit is used to search for the target keyword corresponding to the word contained in the text in the word order container; The second search unit is used to search for the target key value offset corresponding to the target key in the offset order container according to the subscript result of the target key, wherein the subscript result is used to characterize the arrangement order of the target key in the third storage area; The third search unit is used to search for the target value corresponding to the target key value offset in the value order container according to the target key value offset.
17. The apparatus according to claim 16, characterized in that, The first search unit is specifically used to perform a binary search in the word order container to find the target keyword corresponding to the word contained in the text.
18. The apparatus according to any one of claims 10 to 12, characterized in that, The speech synthesis system is used in a portable scanning translation device, which includes a non-volatile storage medium, and the loading process of the rule file is part of the initialization process of the portable scanning translation device.
19. An electronic device, characterized in that, include: processor; as well as A memory storing computer instructions for data processing, which, when executed by the processor, cause the electronic device to perform the method according to any one of claims 1 to 9.
20. A computer-readable storage medium, characterized in that, It contains program instructions for data processing, which, when executed by a processor, implement the method according to any one of claims 1 to 9.