CN107665173B - Voice storage method, voice reading method and device - Google Patents

Voice storage method, voice reading method and device Download PDF

Info

Publication number
CN107665173B
CN107665173B CN201610618040.1A CN201610618040A CN107665173B CN 107665173 B CN107665173 B CN 107665173B CN 201610618040 A CN201610618040 A CN 201610618040A CN 107665173 B CN107665173 B CN 107665173B
Authority
CN
China
Prior art keywords
voice data
address
space
data
voice
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610618040.1A
Other languages
Chinese (zh)
Other versions
CN107665173A (en
Inventor
张洋
张虎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Aiqi Technology Co ltd
Beijing Xiaomi Mobile Software Co Ltd
Original Assignee
Beijing Aiqi Technology Co ltd
Beijing Xiaomi Mobile Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Aiqi Technology Co ltd, Beijing Xiaomi Mobile Software Co Ltd filed Critical Beijing Aiqi Technology Co ltd
Priority to CN201610618040.1A priority Critical patent/CN107665173B/en
Publication of CN107665173A publication Critical patent/CN107665173A/en
Application granted granted Critical
Publication of CN107665173B publication Critical patent/CN107665173B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure relates to a voice storage method, a voice reading method and a voice storage device, and belongs to the technical field of electronics. The method comprises the following steps: receiving the nth voice data to be stored in a voice file, wherein the voice file comprises a data space and a directory space, and n is more than 1; determining the first address of the nth voice data in the data space; storing the first address of the nth voice data in a directory space, and storing the nth voice data in a data space; receiving a reading instruction for reading the stored s-th voice data, wherein s is more than or equal to 1; determining the first address of the s-th voice data in a directory space; and reading the s-th voice data in the data space according to the first address of the s-th voice data. The method and the device can read each piece of voice data in the data space according to the initial address of each piece of voice data stored in the directory space, solve the problem of low voice data reading efficiency, and achieve the effect of improving the voice data reading efficiency.

Description

Voice storage method, voice reading method and device
Technical Field
The present disclosure relates to the field of electronic technologies, and in particular, to a voice storage method, a voice reading method, and a device.
Background
At present, more and more electric toys have a voice playing function, and generally, voice is stored in an MCU (micro controller Unit) in the electric toy or in a Flash (Flash EEPROM Memory) externally connected to the MCU. When a lot of voice contents are stored in the external Flash, how to reliably and efficiently index becomes an urgent problem to be solved.
Disclosure of Invention
In order to solve the problems in the related art, the present disclosure provides a voice storage method, a voice reading method, and a device.
According to a first aspect of the embodiments of the present disclosure, there is provided a method for storing a voice file, the method including:
receiving nth voice data to be stored in a voice file, wherein the voice file comprises a data space and a directory space, the head address of the data space is positioned behind the tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing the head address of each piece of voice data, and n is greater than 1;
determining a head address of the nth voice data in the data space, wherein the head address of the nth voice data is positioned behind a tail address of the (n-1) th voice data;
and storing the first address of the nth voice data after the first address of the (n-1) th voice data in the directory space, and storing the nth voice data at the first address of the nth voice data.
Optionally, the method further includes:
after storing the voice data, calculating the number of the voice data stored in the voice file;
storing the number at a predetermined address of the directory space.
Optionally, the method further includes:
when n is 1, determining the first address of the data space as the first address of the 1 st voice data;
storing the number of pieces of voice data stored in the voice file at the head address of the directory space when the predetermined address is the head address of the directory space;
storing the first address of the 1 st voice data after the end address of the number, and storing the 1 st voice data at the first address of the 1 st voice data.
Optionally, the number of bytes used for storing the number of entries in the directory space is m, the number of bytes used for storing the first address of each piece of voice data is k, and m and k are positive integers.
Optionally, the determining a head address of the nth voice data in the data space includes:
reading the first address of the (n-1) th voice data in the directory space, and acquiring the length of the (n-1) th voice data;
and determining the tail address of the (n-1) th voice data according to the head address of the (n-1) th voice data and the length, and determining the address obtained by adding one to the tail address as the head address of the (n) th voice data.
Optionally, the method further includes:
receiving a deleting instruction for deleting the r-th voice data, wherein r is more than or equal to 1;
determining the first address of the r-th voice data in the directory space according to the deleting instruction;
and deleting the r-th voice data stored in the data space and deleting the head address of the r-th voice data stored in the directory space according to the head address of the r-th voice data.
Optionally, the method further includes:
when r is less than n, the length q of the r-th voice data is obtained, the r + 1-nth voice data is moved forward by the q in the data space, and the first addresses of the r + 1-nth voice data are correspondingly modified in the directory space.
According to a second aspect of the embodiments of the present disclosure, there is provided a voice file reading method, the method including:
receiving a reading instruction for reading the s-th voice data stored in a voice file, wherein the voice file comprises a data space and a directory space, the head address of the data space is positioned behind the tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing the head address of each piece of voice data, and s is more than or equal to 1;
according to the reading instruction, determining the first address of the s-th voice data in the directory space;
and reading the s-th voice data in the data space according to the first address of the s-th voice data.
Optionally, the method further includes:
reading a number of pieces stored at a predetermined address of the directory space, the number of pieces being a number of pieces of voice data stored in the voice file;
and when the s is less than or equal to the number, triggering and executing the step of determining the first address of the s-th voice data in the directory space.
Optionally, the number of bytes used for storing the number of entries in the directory space is m, the number of bytes used for storing the first address of each piece of voice data is k, and m and k are positive integers.
Optionally, when the predetermined address is a first address of the directory space, the determining a first address of the s-th voice data in the directory space includes:
reading the value stored in the m + k (s-1) +1 byte to the m + k (s-1) + k byte in the directory space, and determining the value as the first address of the s-th voice data.
Optionally, the reading the s-th voice data in the data space according to the head address of the s-th voice data includes:
acquiring the length of the s-th voice data, and reading the s-th voice data according to the initial address and the length of the s-th voice data; alternatively, the first and second electrodes may be,
determining the first address of the (s + 1) th voice data, and reading the(s) th voice data according to the address obtained by subtracting one from the first address of the (s + 1) th voice data and the first address of the(s) th voice data.
According to a third aspect of the embodiments of the present disclosure, there is provided a voice storage apparatus, the apparatus comprising:
the data receiving module is configured to receive the nth voice data to be stored in a voice file, the voice file comprises a data space and a directory space, the head address of the data space is located behind the tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing the head address of each piece of voice data, and n is greater than 1;
a first determining module configured to determine a head address of the nth voice data received by the data receiving module in the data space, the head address of the nth voice data being located after a tail address of an (n-1) th voice data;
a first storage module configured to store the first address of the nth voice data determined by the first determination module after the first address of the (n-1) th voice data in the directory space, and store the nth voice data at the first address of the nth voice data.
Optionally, the apparatus further comprises:
a number of pieces calculation module configured to calculate the number of pieces of voice data stored in the voice file after storing the voice data;
a second storage module configured to store the number of pieces calculated by the number of pieces calculation module at a predetermined address of the directory space.
Optionally, the apparatus further comprises:
a second determining module configured to determine a head address of the data space as a head address of the 1 st voice data when n is 1;
a third storage module configured to store the number of pieces of voice data stored in the voice file at the head address of the directory space when the predetermined address is the head address of the directory space;
a fourth storing module configured to store the first address of the 1 st voice data determined by the second determining module after the end address of the number of pieces and store the 1 st voice data at the first address of the 1 st voice data.
Optionally, the number of bytes used for storing the number of entries in the directory space is m, the number of bytes used for storing the first address of each piece of voice data is k, and m and k are positive integers.
Optionally, the initial address determining module includes:
the length obtaining submodule is configured to read the first address of the (n-1) th voice data in the directory space and obtain the length of the (n-1) th voice data;
a head address determining submodule configured to determine a tail address of the n-1 th voice data according to the head address of the n-1 th voice data acquired by the length acquiring submodule and the length, and determine an address obtained by adding one to the tail address as the head address of the n-1 th voice data.
Optionally, the apparatus further comprises:
the instruction receiving module is configured to receive a deleting instruction for deleting the r-th voice data, wherein r is larger than or equal to 1;
a third determining module configured to determine a first address of the r-th voice data in the directory space according to the deleting instruction received by the instruction receiving module;
a data deleting module configured to delete the r-th voice data stored in the data space and delete the head address of the r-th voice data stored in the directory space according to the head address of the r-th voice data determined by the third determining module.
Optionally, the apparatus further comprises:
and the data modification module is configured to obtain the length q of the r-th voice data when r is less than n, move the r + 1-nth voice data forward by the q in the data space, and correspondingly modify the first addresses of the r + 1-nth voice data in the directory space.
According to a fourth aspect of the embodiments of the present disclosure, there is provided a voice reading apparatus, the apparatus including:
the voice file comprises a data space and a directory space, wherein the head address of the data space is positioned behind the tail address of the directory space, the data space is used for storing voice data, the directory space is used for storing the head address of each piece of voice data, and s is more than or equal to 1;
a first address determining module configured to determine a first address of the s-th voice data in the directory space according to the reading instruction received by the instruction receiving module;
a data reading module configured to read the s-th voice data in the data space according to the head address of the s-th voice data determined by the head address determining module.
Optionally, the apparatus further comprises:
a number-of-pieces reading module configured to read a number of pieces stored at a predetermined address of the directory space, the number of pieces being a number of pieces of voice data stored in the voice file;
a number of pieces determining module configured to trigger the step of determining the first address of the s-th voice data in the directory space to be executed when the s is less than or equal to the number of pieces read by the number of pieces reading module.
Optionally, the number of bytes used for storing the number of entries in the directory space is m, the number of bytes used for storing the first address of each piece of voice data is k, and m and k are positive integers.
Optionally, when the predetermined address is the first address of the directory space, the first address determining module is further configured to read a value stored in the m + k (s-1) +1 byte to the m + k (s-1) + k byte in the directory space, and determine the value as the first address of the s-th voice data.
Optionally, the data reading module includes:
the first reading submodule is configured to acquire the length of the s-th voice data, and read the s-th voice data according to the head address and the length of the s-th voice data; alternatively, the first and second electrodes may be,
and the second reading submodule is configured to determine the first address of the (s + 1) th voice data, and read the(s) th voice data according to the address obtained by subtracting one from the first address of the (s + 1) th voice data and the first address of the(s) th voice data.
According to a fifth aspect of the embodiments of the present disclosure, there is provided a voice storage apparatus, the apparatus comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
receiving nth voice data to be stored in a voice file, wherein the voice file comprises a data space and a directory space, the head address of the data space is positioned behind the tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing the head address of each piece of voice data, and n is greater than 1;
determining a head address of the nth voice data in the data space, wherein the head address of the nth voice data is positioned behind a tail address of the (n-1) th voice data;
and storing the first address of the nth voice data after the first address of the (n-1) th voice data in the directory space, and storing the nth voice data at the first address of the nth voice data.
According to a sixth aspect of the embodiments of the present disclosure, there is provided a voice reading apparatus, the apparatus including:
receiving a reading instruction for reading the s-th voice data stored in a voice file, wherein the voice file comprises a data space and a directory space, the head address of the data space is positioned behind the tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing the head address of each piece of voice data, and s is more than or equal to 1;
according to the reading instruction, determining the first address of the s-th voice data in the directory space;
and reading the s-th voice data in the data space according to the first address of the s-th voice data.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
receiving nth voice data to be stored in a voice file, wherein the voice file comprises a data space and a directory space, the head address of the data space is positioned behind the tail address of the directory space, the data space is used for storing the voice data, and the directory space is used for storing the head address of each piece of voice data; determining the first address of the nth voice data in the data space; the first address of the nth voice data is stored after the first address of the (n-1) th voice data in the directory space, and the nth voice data is stored at the first address of the nth voice data, so that when the voice data is read, the first address of the voice data can be read from the directory space firstly, and then the voice data can be read from the first address, the problem of low voice data reading efficiency is solved, and the effect of improving the voice data reading efficiency is achieved.
Any one voice protector in n pieces of voice data can be deleted by receiving a deleting instruction for deleting one piece of voice data, so that the management of the voice data is facilitated.
When s in the read s-th voice data is less than or equal to the number of the voice data stored in the voice file, the operation of reading the s-th voice data is executed, whether the voice file comprises the s-th voice can be determined according to the number of the s-th voice data, the problem that when the s-th voice data is not stored in the voice file, the s-th voice data is still read from the voice file, more processing resources are consumed is solved, and the effect of saving the processing resources is achieved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
FIG. 1 is a diagram illustrating a voice file according to an exemplary embodiment.
FIG. 2 is a flow chart illustrating a method of voice storage according to an exemplary embodiment.
FIG. 3 is a flow chart illustrating a method of voice storage according to another exemplary embodiment.
FIG. 4 is a flow chart illustrating a method of voice reading according to an example embodiment.
Fig. 5 is a flow chart illustrating a voice reading method according to another exemplary embodiment.
FIG. 6 is a block diagram illustrating a voice storage device in accordance with an exemplary embodiment.
FIG. 7 is a block diagram illustrating a voice storage device in accordance with an exemplary embodiment.
Fig. 8 is a block diagram illustrating a voice reading apparatus according to an example embodiment.
Fig. 9 is a block diagram illustrating a voice reading apparatus according to an example embodiment.
Fig. 10 is a block diagram illustrating an apparatus for a voice storage method, voice reading, according to an example embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Fig. 1 is a format of a voice file involved in various embodiments of the present disclosure. Wherein, the voice file comprises a directory space 10 and a data space 20, and the head address of the data space 20 is located behind the tail address of the directory space 10.
The directory space 10 includes, in order, a first space 11 for storing the number of pieces of voice data stored in a voice file, a second space 12 for storing the head address of each piece of voice data in the data space 20, and a reserved third space 13, the third space 13 being used for writing the head address of the voice data. After writing the first address of the voice data in the third space 13, the space where the first address is written is taken as one second space 12. The third space 13 is referred to as offset in fig. 1.
The number of bytes used for storing the number of the entries in the directory space is m, the number of bytes used for storing the first address of each piece of voice data is k, and m and k are positive integers. I.e. the number of bytes in the first space 11 is m and the number of bytes in the second space 12 is k. The number of bytes occupied by the first space 11 may be the same as or different from the number of bytes occupied by each second space 12, and the number of bytes occupied by each second space 12 may be the same. The first space 11 and each second space 12 occupy 4 bytes in fig. 1.
Each piece of voice data is stored in the data space 20, and the head address of the nth piece of voice data is located behind the tail address of the (n-1) th piece of voice data.
Fig. 2 is a flowchart illustrating a voice storing method applied to a terminal according to an exemplary embodiment, and the voice storing method includes the following steps, as shown in fig. 1.
In step 201, an nth piece of voice data to be stored in a voice file is received, where the voice file includes a data space and a directory space, a head address of the data space is located behind a tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing a head address of each piece of voice data, and n > 1.
In step 202, the head address of the nth voice data is determined in the data space, and the head address of the nth voice data is located after the tail address of the (n-1) th voice data.
In step 203, the first address of the nth voice data is stored after the first address of the (n-1) th voice data in the directory space, and the nth voice data is stored at the first address of the nth voice data.
In summary, in the voice storage method provided by the present disclosure, the nth voice data to be stored in the voice file is received, where the voice file includes a data space and a directory space, a head address of the data space is located behind a tail address of the directory space, the data space is used for storing the voice data, and the directory space is used for storing a head address of each piece of voice data; determining the first address of the nth voice data in the data space; the first address of the nth voice data is stored after the first address of the (n-1) th voice data in the directory space, and the nth voice data is stored at the first address of the nth voice data, so that when the voice data is read, the first address of the voice data can be read from the directory space firstly, and then the voice data can be read from the first address, the problem of low voice data reading efficiency is solved, and the effect of improving the voice data reading efficiency is achieved.
Fig. 3 is a flowchart illustrating a voice storing method applied to a terminal according to another exemplary embodiment, and the voice storing method includes the following steps, as shown in fig. 3.
In step 301, an nth piece of voice data to be stored in a voice file is received, where the voice file includes a data space and a directory space, a head address of the data space is located behind a tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing a head address of each piece of voice data, and n > 1.
The voice file refers to a file in which the head address of each piece of voice data and the voice data are stored, and the format of the voice file is shown in fig. 1. The first address of the data space refers to the start address of the data space, the last address of the directory space refers to the end address of the directory space, and the address one bit after the last address of the directory space is the first address of the data space.
In step 302, the first address of the (n-1) th voice data is read in the directory space, and the length of the (n-1) th voice data is obtained.
The n-1 th piece of voice data is a piece of voice data before the nth piece of voice data. The first address of the (n-1) th voice data is the starting address of the (n-1) th voice data in the data space.
Since the head address of the nth voice data is located behind the tail address of the (n-1) th voice data, the terminal needs to determine the head address of the nth voice data according to the tail address of the (n-1) th voice data. As the directory space stores the head address of the (n-1) th voice data and the terminal stores the length of the (n-1) th voice data when the (n-1) th voice data is stored in the data space, the terminal can determine the tail address of the (n-1) th voice data according to the head address and the length of the (n-1) th voice data. The tail address of the (n-1) th voice data is the end address of the (n-1) th voice data in the data space.
In step 303, the tail address of the (n-1) th voice data is determined according to the head address and the length of the (n-1) th voice data, and an address obtained by adding one to the tail address is determined as the head address of the nth voice data.
After the tail address of the (n-1) th voice data is determined, the terminal adds one to the tail address of the (n-1) th voice data to obtain an address which is the head address of the nth voice data.
In step 304, the first address of the nth voice data is stored after the first address of the (n-1) th voice data in the directory space, and the nth voice data is stored at the first address of the nth voice data.
After determining the head address of the nth voice data, the terminal reads the head address of the nth voice data, stores the head address in an address following the head address of the (n-1) th voice data in the directory space, and starts storing the nth voice data at the head address of the nth voice data.
For example, the first address of the nth voice data is 00ff, and the second space storing the first address of the (n-1) th voice data is 9-12 bytes, the terminal stores 00ff in the second space of 13-16 bytes.
In step 305, after storing the voice data, the number of pieces of voice data stored in the voice file is calculated.
The number of pieces of voice data refers to the number of pieces of voice data stored in the voice file.
In step 306, the number of stripes is stored at a predetermined address of the directory space.
The terminal can also store the number of the voice data stored in the voice file, so that when the terminal needs to read a certain piece of voice data, the terminal can firstly judge whether the voice file stores the piece of voice data or not according to the number, and then reads the piece of voice data after the voice data is determined to be stored in the voice file.
The predetermined address refers to an address of the directory space for storing the number of pieces of voice data, and in this embodiment, the predetermined address is a first address of the directory space.
The above step 301-. At this time, when n is 1, determining the first address of the data space as the first address of the 1 st voice data; storing the number of pieces of voice data stored in the voice file at the first address of the directory space when the predetermined address is the first address of the directory space; the first address of the 1 st voice data is stored after the end address of the number of pieces, and the 1 st voice data is stored at the first address of the 1 st voice data.
The number of bytes used for storing the number of the entries in the directory space is m, the number of bytes used for storing the first address of each piece of voice data is k, and m and k are positive integers.
The number of the pieces of the voice data and the first address of each piece of the voice data both occupy a certain number of bytes, if the number of bytes used for storing the number of pieces in the directory space is m, the number of bytes used for storing the first address of each piece of the voice data is k, and m and k may be equal or unequal. For example: m is 4, k is 3, or m is 3.
For ease of understanding, the storage of the voice data is explained below as an example. Assuming that m-k-4 and the head address of the data space is the 120 th byte, when storing the 1 st voice data, the terminal determines that the head address of the 1 st voice data is the 121 th byte, stores the value 121 in the 5 th to 8 th bytes, stores the 1 st voice data from the 121 th byte, and stores the value 1 in the 1 st to 4 th bytes after successful storage; when the 2 nd voice data is stored, assuming that the length of the 1 st voice data is 10 bytes, determining that the tail address of the 1 st voice data is 130 bytes, the head address of the 2 nd voice data is 131 bytes, storing the numerical value 131 in the 9 th to 12 th bytes, and storing the 2 nd voice data from the 131 th byte, after successful storage, modifying the numerical value 1 stored in the 1 st to 4 th bytes into the numerical value 2, and then, the storage mode of each voice data is the same as that of the 2 nd voice data, and no further description is given.
After storing n pieces of voice data, if the terminal needs to delete one piece of voice data, step 307 may be executed.
In step 307, a delete command for deleting the r-th voice data is received, where r is greater than or equal to 1.
In step 308, the first address of the r-th voice data is determined in the directory space according to the delete command.
If the nth voice data is to be deleted, the terminal needs to find the nth voice data in the data space, that is, the terminal needs to determine the first address of the nth voice data in the directory space, and then find the nth voice data in the data space according to the first address of the nth voice data.
When determining the first address of the r-th voice data in the directory space, the terminal needs to determine the m + k (r-1) +1 byte to the m + k (r-1) + k bytes first, and read the first address of the r-th voice data from the k bytes.
In step 309, according to the head address of the r-th voice data, the r-th voice data stored in the data space is deleted, and the head address of the r-th voice data stored in the directory space is deleted.
After the head address of the r-th voice data is determined, the terminal further needs to determine the r-th voice data according to the head address of the r-th voice data. In one implementation mode, a terminal acquires the length of the r-th voice data, and determines the r-th voice data according to the initial address and the length of the r-th voice data; in a second implementation manner, when r is less than n, the terminal reads the head address of the r +1 th voice data, subtracts one from the head address of the r +1 th voice data to obtain the tail address of the r voice data, and determines the r voice data according to the head address of the r voice data and the tail address of the r voice data.
After the nth voice data is determined, the terminal deletes the tth voice data, and then deletes the first address of the mth voice data stored in the k bytes from the m + k (r-1) +1 byte to the m + k (r-1) + k byte.
When r is equal to n, the terminal also needs to modify the number of the strips, and the process is ended; when r is less than n, the terminal also needs to modify the number of the pieces and recycle the storage space for storing the r-th voice data so as to improve the utilization rate of the storage space.
In step 310, when r is less than n, the length q of the r-th voice data is obtained, the r + 1-th voice data to the n-th voice data are moved forward by q in the data space, and the first addresses of the r + 1-th voice data to the n-th voice data are modified correspondingly in the directory space.
After deleting the r-th voice data in the n pieces of voice data, the terminal needs to move the r + 1-th voice data to the n-th voice data in the data space forward by the length of the r-th voice data, and correspondingly modify the first addresses of the r + 1-th voice data to the n-th voice data in the directory space.
For ease of understanding, the storage of the voice data is explained below as an example. Assuming that m-k-4 and the terminal needs to delete the 3 rd voice data in the 5 th voice data, the terminal reads the value 121 of the head address of the 3 rd voice data from the 13 th-16 th bytes, reads the value 131 of the head address of the 4 th voice data from the 17 th-20 th bytes, determines that the 3 rd voice data is stored in the 121 th-130 th bytes, deletes the data in the 121 th-130 th bytes and deletes the value in the 13 th-16 th bytes, and modifies the value 5 in the 1 st-4 th bytes to 4. The terminal also advances the head addresses of the 4 th voice data and the 5 th voice data by 10 bytes, and decrements the values in the 17 th to 20 th bytes and the 21 th to 24 th bytes by 10, respectively.
In summary, in the voice storage method provided by the present disclosure, the nth voice data to be stored in the voice file is received, where the voice file includes a data space and a directory space, a head address of the data space is located behind a tail address of the directory space, the data space is used for storing the voice data, and the directory space is used for storing a head address of each piece of voice data; determining the first address of the nth voice data in the data space; the first address of the nth voice data is stored after the first address of the (n-1) th voice data in the directory space, and the nth voice data is stored at the first address of the nth voice data, so that when the voice data is read, the first address of the voice data can be read from the directory space firstly, and then the voice data can be read from the first address, the problem of low voice data reading efficiency is solved, and the effect of improving the voice data reading efficiency is achieved.
Any one voice protector in n pieces of voice data can be deleted by receiving a deleting instruction for deleting one piece of voice data, so that the management of the voice data is facilitated.
After n pieces of voice data are stored, n is greater than or equal to 1, and the terminal can read any piece of voice data, as described in the following embodiments.
Fig. 4 is a flowchart illustrating a voice reading method applied to a terminal according to another exemplary embodiment, and the voice reading method includes the following steps, as shown in fig. 4.
In step 401, a reading instruction for reading the s-th voice data stored in the voice file is received, where the voice file includes a data space and a directory space, a head address of the data space is located behind a tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing the head address of each piece of voice data, and s is greater than or equal to 1;
in step 402, according to the reading instruction, determining the first address of the s-th voice data in the directory space;
in step 403, the s-th voice data is read in the data space according to the first address of the s-th voice data.
In summary, in the voice reading method provided by the present disclosure, by receiving a reading instruction for reading the s-th voice data stored in the voice file, s is greater than or equal to 1; determining the first address of the s-th voice data in the directory space according to the reading instruction; the method comprises the steps of reading the voice data of the second item from the data space according to the first address of the voice data of the second item, reading the first address of the voice data from the directory space when the voice data are read, and reading the voice data from the first address, so that the problem of low voice data reading efficiency is solved, and the effect of improving the voice data reading efficiency is achieved.
Fig. 5 is a flowchart illustrating a voice reading method applied to a terminal according to another exemplary embodiment, and the voice reading method includes the following steps, as shown in fig. 5.
In step 501, a reading instruction for reading the s-th voice data stored in a voice file is received, where the voice file includes a data space and a directory space, a head address of the data space is located behind a tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing a head address of each piece of voice data, and s is greater than or equal to 1.
The voice file refers to a file in which the head address of each piece of voice data and the voice data are stored, and the format of the voice file is shown in fig. 1. The first address of the data space refers to the start address of the data space, the last address of the directory space refers to the end address of the directory space, and the address one bit after the last address of the directory space is the first address of the data space.
In step 502, the number of pieces stored at a predetermined address of the directory space, which is the number of pieces of voice data stored in the voice file, is read.
Since the voice file may not store the s-th voice data, at this time, reading the s-th data in the voice file wastes processing resources, so that the terminal may also read the number of pieces of voice data stored in the voice file before reading the s-th voice data, and then compare s with the number of pieces of voice data stored in the voice file to determine whether to read the s-th voice data.
In step 503, when s is less than or equal to the number of pieces, step 504 is triggered to be executed.
When s is less than or equal to the number of the pieces, it is indicated that the voice file stores the s-th voice data, and step 504 is executed; and when the s is more than the number of the s, the voice file does not store the s-th voice data, and the process is ended.
In step 504, the values stored in the m + k (s-1) +1 byte to the m + k (s-1) + k byte in the directory space are read, and the values are determined as the first address of the s-th voice data.
The first address of the s-th voice data is the starting address of the s-th voice data in the data space.
In this embodiment, the number of bytes used for storing the number of entries in the directory space is m, and the number of bytes used for storing the first address of each piece of voice data is k, so that the terminal can determine that the first address of the s-th piece of voice data is stored in the (m + k) (s-1) +1 byte to the (m + k) (s-1) + k byte.
After the terminal obtains the head address of the s-th voice data, the terminal needs to determine the tail address of the s-th voice data to read the s-th voice data, and at this time, the terminal executes step 505 or 506.
In step 505, the length of the s-th voice data is obtained, and the s-th voice data is read according to the head address and the length of the s-th voice data.
After the head address of the s-th voice data is determined, the terminal reads the length of the s-th voice data recorded when the s-th voice data is stored in the data space, so that the terminal can determine the tail address of the s-th voice data according to the head address and the length of the s-th voice data.
For ease of understanding, the storage of the voice data is explained below as an example. Assuming that m is 4 and the terminal needs to read the 3 rd voice data in the 5 th voice data, the terminal reads the value 121 of the first address of the 3 rd voice data from the 13 th-16 th bytes and acquires that the length of the 3 rd voice data is 10 bytes, determines that the 3 rd voice data is stored in the 121 th-130 th bytes, and reads the 3 rd voice data from the 121 th-130 th bytes.
In step 506, the first address of the (s + 1) th voice data is determined, and the(s) th voice data is read according to the address obtained by subtracting one from the first address of the (s + 1) th voice data and the first address of the(s) th voice data.
The (s + 1) th piece of voice data is one piece of voice data subsequent to the s-th piece of voice data.
Since the end address of the s +1 th voice data is located before the head address of the s +1 th voice data, the terminal needs to determine the end address of the s +1 th voice data according to the head address of the s +1 th voice data. Since the directory space stores the head address of the (s + 1) th voice data, the terminal can subtract one from the head address of the (s + 1) th voice data to obtain the tail address of the(s) th voice data.
For ease of understanding, the storage of the voice data is explained below as an example. Assuming that m is 4 and the terminal needs to read the 3 rd voice data in the 5 th voice data, the terminal reads the value 121 of the head address of the 3 rd voice data from the 13 th to 16 th bytes, reads the value 131 of the head address of the 4 th voice data from the 17 th to 20 th bytes, determines that the 3 rd voice data is stored in the 121 th and 130 th bytes, and reads the 3 rd voice data from the 121 th and 130 th bytes.
In summary, in the voice reading method provided by the present disclosure, by receiving a reading instruction for reading the s-th voice data stored in the voice file, s is greater than or equal to 1; determining the first address of the s-th voice data in the directory space according to the reading instruction; the method comprises the steps of reading the voice data of the second item from the data space according to the first address of the voice data of the second item, reading the first address of the voice data from the directory space when the voice data are read, and reading the voice data from the first address, so that the problem of low voice data reading efficiency is solved, and the effect of improving the voice data reading efficiency is achieved.
When s in the read s-th voice data is less than or equal to the number of the voice data stored in the voice file, the operation of reading the s-th voice data is executed, whether the voice file comprises the s-th voice can be determined according to the number of the s-th voice data, the problem that when the s-th voice data is not stored in the voice file, the s-th voice data is still read from the voice file, more processing resources are consumed is solved, and the effect of saving the processing resources is achieved.
Fig. 6 is a block diagram illustrating a voice storage apparatus applied to a terminal according to an exemplary embodiment, the voice storage apparatus, as shown in fig. 6, including: a data receiving module 610, a first determining module 620 and a first storing module 630;
the data receiving module 610 is configured to receive an nth piece of voice data to be stored in a voice file, where the voice file includes a data space and a directory space, a head address of the data space is located behind a tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing the head address of each piece of voice data, and n > 1;
the first determining module 620 is configured to determine a head address of the nth voice data received by the data receiving module 610 in the data space, where the head address of the nth voice data is located after a tail address of the (n-1) th voice data;
the first storing module 630 is configured to store the first address of the nth voice data determined by the first determining module 620 after the first address of the (n-1) th voice data in the directory space, and store the nth voice data at the first address of the nth voice data.
In summary, the voice storage apparatus provided by the present disclosure receives the nth voice data to be stored in the voice file, where the voice file includes a data space and a directory space, a head address of the data space is located behind a tail address of the directory space, the data space is used for storing the voice data, and the directory space is used for storing a head address of each piece of voice data; determining the first address of the nth voice data in the data space; the first address of the nth voice data is stored after the first address of the (n-1) th voice data in the directory space, and the nth voice data is stored at the first address of the nth voice data, so that when the voice data is read, the first address of the voice data can be read from the directory space firstly, and then the voice data can be read from the first address, the problem of low voice data reading efficiency is solved, and the effect of improving the voice data reading efficiency is achieved.
Fig. 7 is a block diagram illustrating a voice storage apparatus applied to a terminal according to an exemplary embodiment, the voice storage apparatus, as shown in fig. 7, including: a data receiving module 710, a first determining module 720 and a first storing module 730;
the data receiving module 710 is configured to receive an nth piece of voice data to be stored in a voice file, where the voice file includes a data space and a directory space, a head address of the data space is located behind a tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing the head address of each piece of voice data, and n > 1;
the first determining module 720 is configured to determine a first address of the nth voice data received by the data receiving module 710 in the data space, wherein the first address of the nth voice data is located after a last address of the (n-1) th voice data;
the first storing module 730 is configured to store the first address of the nth voice data determined by the first determining module 720 after the first address of the (n-1) th voice data in the directory space, and store the nth voice data at the first address of the nth voice data.
Optionally, the apparatus further comprises: a number of bars calculation module 740 and a second storage module 750;
the number of pieces calculating module 740 configured to calculate the number of pieces of voice data stored in the voice file after storing the voice data;
the second storage module 750 is configured to store the number of pieces calculated by the number of pieces calculation module 740 at a predetermined address of the directory space.
Optionally, the apparatus further comprises: a second determination module 760, a third storage module 770, and a fourth storage module 780;
the second determining module 760 is configured to determine the first address of the data space as the first address of the 1 st voice data when n is 1;
the third storage module 770 configured to store the number of pieces of voice data stored in the voice file at the head address of the directory space when the predetermined address is the head address of the directory space;
the fourth storing module 780 is configured to store the first address of the 1 st voice data determined by the second determining module 760 after the end address of the number of pieces, and store the 1 st voice data at the first address of the 1 st voice data.
Optionally, the number of bytes used for storing the number of entries in the directory space is m, the number of bytes used for storing the first address of each piece of voice data is k, and m and k are positive integers.
Optionally, the first determining module 720 includes: a length acquisition submodule 721 and a head address determination submodule 722;
the length obtaining sub-module 721 is configured to read the first address of the (n-1) th voice data in the directory space, and obtain the length of the (n-1) th voice data;
the head address determining submodule 722 is configured to determine a tail address of the n-1 th voice data according to the head address and the length of the n-1 th voice data acquired by the length acquiring submodule 721, and determine an address obtained by adding one to the tail address as the head address of the n-th voice data.
Optionally, the apparatus further comprises: an instruction receiving module 790, a third determining module 791, and a data deleting module 792;
the instruction receiving module 790 is configured to receive a deletion instruction for deleting the r-th voice data, wherein r is greater than or equal to 1;
the third determining module 791, configured to determine the first address of the r-th piece of voice data in the directory space according to the deleting instruction received by the instruction receiving module 790;
the data deleting module 792 is configured to delete the r-th voice data stored in the data space and delete the head address of the r-th voice data stored in the directory space according to the head address of the r-th voice data determined by the third determining module 791.
Optionally, the apparatus further comprises: a data modification module 793;
the data modification module 793 is configured to, when r is less than n, obtain a length q of the r-th voice data, move the r + 1-th voice data to the n-th voice data forward by q in the data space, and correspondingly modify the first addresses of the r + 1-th voice data to the n-th voice data in the directory space.
In summary, the voice storage apparatus provided by the present disclosure receives the nth voice data to be stored in the voice file, where the voice file includes a data space and a directory space, a head address of the data space is located behind a tail address of the directory space, the data space is used for storing the voice data, and the directory space is used for storing a head address of each piece of voice data; determining the first address of the nth voice data in the data space; the first address of the nth voice data is stored after the first address of the (n-1) th voice data in the directory space, and the nth voice data is stored at the first address of the nth voice data, so that when the voice data is read, the first address of the voice data can be read from the directory space firstly, and then the voice data can be read from the first address, the problem of low voice data reading efficiency is solved, and the effect of improving the voice data reading efficiency is achieved.
Any one voice protector in n pieces of voice data can be deleted by receiving a deleting instruction for deleting one piece of voice data, so that the management of the voice data is facilitated.
Fig. 8 is a block diagram illustrating a voice reading apparatus according to an exemplary embodiment, the voice reading apparatus being applied to a terminal, as shown in fig. 8, the voice reading apparatus including: an instruction receiving module 810, a first address determining module 820 and a data reading module 830;
the instruction receiving module 810 is configured to receive a reading instruction for reading an s-th voice data stored in a voice file, where the voice file includes a data space and a directory space, a head address of the data space is located behind a tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing a head address of each piece of voice data, and s is greater than or equal to 1;
the first address determining module 820 is configured to determine a first address of the s-th voice data in the directory space according to the reading instruction received by the instruction receiving module 810;
the data reading module 830 is configured to read the s-th voice data in the data space according to the first address of the s-th voice data determined by the first address determining module 820.
In summary, the voice reading apparatus provided by the present disclosure receives a reading instruction for reading the s-th voice data stored in the voice file, where s is greater than or equal to 1; determining the first address of the s-th voice data in the directory space according to the reading instruction; the method comprises the steps of reading the voice data of the second item from the data space according to the first address of the voice data of the second item, reading the first address of the voice data from the directory space when the voice data are read, and reading the voice data from the first address, so that the problem of low voice data reading efficiency is solved, and the effect of improving the voice data reading efficiency is achieved.
Fig. 9 is a block diagram illustrating a voice reading apparatus according to an exemplary embodiment, the voice reading apparatus being applied to a terminal, as shown in fig. 9, the voice reading apparatus including: an instruction receiving module 910, a first address determining module 920 and a data reading module 930;
the instruction receiving module 910 is configured to receive a reading instruction for reading an s-th voice data stored in a voice file, where the voice file includes a data space and a directory space, a head address of the data space is located behind a tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing a head address of each piece of voice data, and s is greater than or equal to 1;
the first address determining module 920 is configured to determine a first address of the s-th voice data in the directory space according to the reading instruction received by the instruction receiving module 910;
the data reading module 930 is configured to read the s-th voice data in the data space according to the first address of the s-th voice data determined by the first address determining module 920.
Optionally, the apparatus further comprises: a number reading module 940 and a number determining module 950;
the number-of-pieces reading module 940 configured to read the number of pieces stored at a predetermined address of the directory space, the number of pieces being the number of pieces of voice data stored in the voice file;
the number-of-pieces determining module 950 is configured to trigger the step of determining the first address of the s-th voice data in the directory space when s is smaller than or equal to the number of pieces read by the number-of-pieces reading module 940.
Optionally, the number of bytes used for storing the number of entries in the directory space is m, the number of bytes used for storing the first address of each piece of voice data is k, and m and k are positive integers.
Optionally, when the predetermined address is the first address of the directory space, the first address determining module 920 is further configured to read the values stored in the m + k (s-1) +1 byte to the m + k (s-1) + k byte in the directory space, and determine the values as the first address of the s-th voice data.
Optionally, the data reading module 930 includes: a first reading sub-module 931 and a second reading sub-module 932;
the first reading sub-module 931 configured to obtain the length of the s-th voice data, and read the s-th voice data according to the head address and the length of the s-th voice data; alternatively, the first and second electrodes may be,
the second reading submodule 932 is configured to determine a first address of the (s + 1) th voice data, and read the(s) th voice data according to an address obtained by subtracting one from the first address of the (s + 1) th voice data and the first address of the(s) th voice data.
In summary, the voice reading apparatus provided by the present disclosure receives a reading instruction for reading the s-th voice data stored in the voice file, where s is greater than or equal to 1; determining the first address of the s-th voice data in the directory space according to the reading instruction; the method comprises the steps of reading the voice data of the second item from the data space according to the first address of the voice data of the second item, reading the first address of the voice data from the directory space when the voice data are read, and reading the voice data from the first address, so that the problem of low voice data reading efficiency is solved, and the effect of improving the voice data reading efficiency is achieved.
When s in the read s-th voice data is less than or equal to the number of the voice data stored in the voice file, the operation of reading the s-th voice data is executed, whether the voice file comprises the s-th voice can be determined according to the number of the s-th voice data, the problem that when the s-th voice data is not stored in the voice file, the s-th voice data is still read from the voice file, more processing resources are consumed is solved, and the effect of saving the processing resources is achieved.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
An exemplary embodiment of the present disclosure provides a voice storage apparatus capable of implementing a voice storage method provided by the present disclosure, the voice storage apparatus including: a processor, a memory for storing processor-executable instructions;
wherein the processor is configured to:
receiving nth voice data to be stored in a voice file, wherein the voice file comprises a data space and a directory space, the head address of the data space is positioned behind the tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing the head address of each piece of voice data, and n is greater than 1;
determining the head address of the nth voice data in the data space, wherein the head address of the nth voice data is positioned behind the tail address of the (n-1) th voice data;
the first address of the nth voice data is stored after the first address of the (n-1) th voice data in the directory space, and the nth voice data is stored at the first address of the nth voice data.
An exemplary embodiment of the present disclosure provides a voice reading apparatus capable of implementing a voice reading method provided by the present disclosure, the voice reading apparatus including: a processor, a memory for storing processor-executable instructions;
wherein the processor is configured to:
receiving a reading instruction for reading the s-th voice data stored in a voice file, wherein the voice file comprises a data space and a directory space, the head address of the data space is positioned behind the tail address of the directory space, the data space is used for storing the voice data, the directory space is used for storing the head address of each piece of voice data, and s is more than or equal to 1;
determining the first address of the s-th voice data in the directory space according to the reading instruction;
and reading the s-th voice data in the data space according to the first address of the s-th voice data.
Fig. 10 is a block diagram illustrating an apparatus 1000 for a voice storage method, voice reading, according to an example embodiment. For example, the apparatus 1000 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 10, the apparatus 1000 may include one or more of the following components: processing component 1002, memory 1004, power component 1006, multimedia component 1008, audio component 1010, input/output (I/O) interface 1012, sensor component 1014, and communications component 1016.
The processing component 1002 generally controls the overall operation of the device 1000, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 1002 may include one or more processors 1018 to execute instructions to perform all or a portion of the steps of the methods described above. Further, processing component 1002 may include one or more modules that facilitate interaction between processing component 1002 and other components. For example, the processing component 1002 may include a multimedia module to facilitate interaction between the multimedia component 1008 and the processing component 1002.
The memory 1004 is configured to store various types of data to support operations at the apparatus 1000. Examples of such data include instructions for any application or method operating on device 1000, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 1004 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power supply component 1006 provides power to the various components of the device 1000. The power components 1006 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 1000.
The multimedia component 1008 includes a screen that provides an output interface between the device 1000 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1008 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the device 1000 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 1010 is configured to output and/or input audio signals. For example, audio component 1010 includes a Microphone (MIC) configured to receive external audio signals when apparatus 1000 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal may further be stored in the memory 1004 or transmitted via the communication component 1016. In some embodiments, audio component 1010 also includes a speaker for outputting audio signals.
I/O interface 1012 provides an interface between processing component 1002 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 1014 includes one or more sensors for providing various aspects of status assessment for the device 1000. For example, sensor assembly 1014 may detect an open/closed state of device 1000, the relative positioning of components, such as a display and keypad of device 1000, the change in position of device 1000 or a component of device 1000, the presence or absence of user contact with device 1000, the orientation or acceleration/deceleration of device 1000, and the change in temperature of device 1000. The sensor assembly 1014 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 1014 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1014 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 1016 is configured to facilitate communications between the apparatus 1000 and other devices in a wired or wireless manner. The device 1000 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 1016 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communications component 1016 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 1000 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer readable storage medium comprising instructions, such as the memory 1004 comprising instructions, executable by the processor 1018 of the apparatus 1000 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (18)

1. A method of speech storage, the method comprising:
receiving nth voice data to be stored in a voice file, wherein the voice file comprises a data space and a directory space, the head address of the data space is positioned behind the tail address of the directory space, the data space is used for storing the voice data, the directory space comprises a first space, a second space and a third space, the first space is used for storing the number of the voice data stored in the voice file, the second space is used for storing the head address of each piece of the voice data in the data space, the third space is used for writing the head address of the voice data, n is greater than 1, the number of bytes used for storing the number of the voice data in the directory space is m, the number of bytes used for storing the head address of each piece of the voice data is k, and m and k are positive integers;
determining a head address of the nth voice data in the data space, wherein the head address of the nth voice data is positioned behind a tail address of the (n-1) th voice data;
storing a first address of the nth voice data after a first address of the (n-1) th voice data in the directory space, and storing the nth voice data at the first address of the nth voice data;
after storing the voice data, calculating the number of the voice data stored in the voice file;
storing the number at a preset address of the directory space, wherein the number is used for judging whether the voice data is stored in the voice file or not according to the number when the voice data is read, and the preset address is a first address of the directory space;
receiving a deleting instruction for deleting the r-th voice data, wherein r is more than or equal to 1;
according to the deleting instruction, determining m + k (r-1) +1 byte to m + k (r-1) + k bytes in the directory space, and reading the head address of the r voice data from the k bytes;
deleting the r-th voice data stored in the data space according to the head address of the r-th voice data, and deleting the head address of the r-th voice data stored in the k bytes from the m + k (r-1) +1 byte to the m + k (r-1) + k byte;
when r is n, modifying the number of the strips;
and when r is less than n, modifying the number of the pieces, and recycling the storage space for storing the r-th voice data.
2. The method of claim 1, further comprising:
when n is 1, determining the first address of the data space as the first address of the 1 st voice data;
storing the number of pieces of voice data stored in the voice file at the head address of the directory space when the predetermined address is the head address of the directory space;
storing the first address of the 1 st voice data after the end address of the number, and storing the 1 st voice data at the first address of the 1 st voice data.
3. The method according to claim 1 or 2, wherein the determining the first address of the nth voice data in the data space comprises:
reading the first address of the (n-1) th voice data in the directory space, and acquiring the length of the (n-1) th voice data;
and determining the tail address of the (n-1) th voice data according to the head address of the (n-1) th voice data and the length, and determining the address obtained by adding one to the tail address as the head address of the (n) th voice data.
4. The method of claim 1, further comprising:
when r is less than n, the length q of the r-th voice data is obtained, the r + 1-nth voice data is moved forward by the q in the data space, and the first addresses of the r + 1-nth voice data are correspondingly modified in the directory space.
5. A voice reading method for reading voice data stored by the method of any one of claims 1 to 4, the method comprising:
receiving a reading instruction for reading the s-th voice data stored in a voice file, wherein the voice file comprises a data space and a directory space, the head address of the data space is positioned behind the tail address of the directory space, the data space is used for storing the voice data, the directory space comprises a first space, a second space and a third space, the first space is used for storing the number of the voice data stored in the voice file, the second space is used for storing the head address of each piece of the voice data in the data space, the third space is used for writing the head address of the voice data, and s is larger than or equal to 1;
according to the reading instruction, determining the first address of the s-th voice data in the directory space;
reading the s-th voice data in the data space according to the initial address of the s-th voice data;
reading the number of pieces stored at a preset address of the directory space, wherein the number of pieces is the number of pieces of voice data stored in the voice file, the number of pieces is used for judging whether the voice data is stored in the voice file or not according to the number of pieces when the voice data is read, and the preset address is the first address of the directory space;
and when the s is less than or equal to the number, triggering and executing the step of determining the first address of the s-th voice data in the directory space.
6. The method of claim 5, wherein the number of bytes in the directory space used to store the number of entries is m, the number of bytes used to store the first address of each piece of voice data is k, and m and k are positive integers.
7. The method according to claim 6, wherein when the predetermined address is a first address of the directory space, the determining a first address of the s-th piece of voice data in the directory space comprises:
reading the value stored in the m + k (s-1) +1 byte to the m + k (s-1) + k byte in the directory space, and determining the value as the first address of the s-th voice data.
8. The method according to any one of claims 5 to 7, wherein said reading the s-th voice data in the data space according to the first address of the s-th voice data comprises:
acquiring the length of the s-th voice data, and reading the s-th voice data according to the initial address and the length of the s-th voice data; alternatively, the first and second electrodes may be,
determining the first address of the (s + 1) th voice data, and reading the(s) th voice data according to the address obtained by subtracting one from the first address of the (s + 1) th voice data and the first address of the(s) th voice data.
9. A speech storage device, the device comprising:
a data receiving module, configured to receive an nth piece of voice data to be stored in a voice file, where the voice file includes a data space and a directory space, a head address of the data space is located behind a tail address of the directory space, and the data space is used for storing the voice data, the directory space includes a first space, a second space, and a third space, the first space is used for storing a number of pieces of voice data stored in the voice file, the second space is used for storing a head address of each piece of voice data in the data space, the third space is used for writing a head address of the voice data, n is greater than 1, a number of bytes in the directory space is m, a number of bytes in the first address used for storing each piece of voice data is k, and m and k are positive integers;
a first determining module configured to determine a head address of the nth voice data received by the data receiving module in the data space, the head address of the nth voice data being located after a tail address of an (n-1) th voice data;
a first storage module configured to store the first address of the nth voice data determined by the first determination module after the first address of the (n-1) th voice data in the directory space and store the nth voice data at the first address of the nth voice data;
a number of pieces calculation module configured to calculate the number of pieces of voice data stored in the voice file after storing the voice data;
a second storage module configured to store the number calculated by the number-of-pieces calculation module at a predetermined address of the directory space, where the number is used to determine whether the voice data is stored in the voice file according to the number when the voice data is read, and the predetermined address is a first address of the directory space;
the instruction receiving module is configured to receive a deleting instruction for deleting the r-th voice data, wherein r is larger than or equal to 1;
a third determining module configured to determine m + k (r-1) +1 byte to m + k (r-1) + k bytes in the directory space according to the deleting instruction, and read a first address of the r voice data from the k bytes;
a data deleting module configured to delete the r-th voice data stored in the data space according to a head address of the r-th voice data, and delete a head address of the r-th voice data stored in k bytes from an m + k (r-1) +1 byte to an m + k (r-1) + k bytes;
a data modification module, modifying the number when r is n;
and when r is less than n, modifying the number of the pieces, and recycling the storage space for storing the r-th voice data.
10. The apparatus of claim 9, further comprising:
a second determining module configured to determine a head address of the data space as a head address of the 1 st voice data when n is 1;
a third storage module configured to store the number of pieces of voice data stored in the voice file at the head address of the directory space when the predetermined address is the head address of the directory space;
a fourth storing module configured to store the first address of the 1 st voice data determined by the second determining module after the end address of the number of pieces and store the 1 st voice data at the first address of the 1 st voice data.
11. The apparatus of claim 9 or 10, wherein the first determining module comprises:
the length obtaining submodule is configured to read the first address of the (n-1) th voice data in the directory space and obtain the length of the (n-1) th voice data;
a head address determining submodule configured to determine a tail address of the n-1 th voice data according to the head address of the n-1 th voice data acquired by the length acquiring submodule and the length, and determine an address obtained by adding one to the tail address as the head address of the n-1 th voice data.
12. The apparatus of claim 9, further comprising:
and the data modification module is configured to obtain the length q of the r-th voice data when r is less than n, move the r + 1-nth voice data forward by the q in the data space, and correspondingly modify the first addresses of the r + 1-nth voice data in the directory space.
13. A voice reading apparatus for reading voice data stored in the apparatus of any one of claims 9 to 12, the apparatus comprising:
the instruction receiving module is configured to receive a reading instruction for reading the s-th voice data stored in a voice file, the voice file comprises a data space and a directory space, the head address of the data space is located behind the tail address of the directory space, the data space is used for storing the voice data, the directory space comprises a first space, a second space and a third space, the first space is used for storing the number of the voice data stored in the voice file, the second space is used for storing the head address of each piece of voice data in the data space, the third space is used for writing the head address of the voice data, and s is larger than or equal to 1;
a first address determining module configured to determine a first address of the s-th voice data in the directory space according to the reading instruction received by the instruction receiving module;
a data reading module configured to read the s-th voice data in the data space according to the first address of the s-th voice data determined by the first address determining module;
a number reading module configured to read a number stored at a predetermined address of the directory space, where the number is a number of pieces of voice data stored in the voice file, and the number is used to determine whether the voice data is stored in the voice file according to the number when the voice data is read, and the predetermined address is a first address of the directory space;
a number of pieces determining module configured to trigger the step of determining the first address of the s-th voice data in the directory space to be executed when the s is less than or equal to the number of pieces read by the number of pieces reading module.
14. The apparatus of claim 13, wherein the number of bytes in the directory space used to store the number of entries is m, the number of bytes used to store the first address of each piece of voice data is k, and m and k are positive integers.
15. The apparatus according to claim 14, wherein when the predetermined address is a first address of the directory space, the first address determining module is further configured to read a value stored in an m + k (s-1) +1 byte to an m + k (s-1) + k byte in the directory space, and determine the value as a first address of the s-th voice data.
16. The apparatus of any one of claims 13 to 15, wherein the data reading module comprises:
the first reading submodule is configured to acquire the length of the s-th voice data, and read the s-th voice data according to the head address and the length of the s-th voice data; alternatively, the first and second electrodes may be,
and the second reading submodule is configured to determine the first address of the (s + 1) th voice data, and read the(s) th voice data according to the address obtained by subtracting one from the first address of the (s + 1) th voice data and the first address of the(s) th voice data.
17. A voice file storage apparatus, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
receiving nth voice data to be stored in a voice file, wherein the voice file comprises a data space and a directory space, the head address of the data space is positioned behind the tail address of the directory space, the data space is used for storing the voice data, the directory space comprises a first space, a second space and a third space, the first space is used for storing the number of the voice data stored in the voice file, the second space is used for storing the head address of each piece of the voice data in the data space, the third space is used for writing the head address of the voice data, n is greater than 1, the number of bytes used for storing the number of the voice data in the directory space is m, the number of bytes used for storing the head address of each piece of the voice data is k, and m and k are positive integers;
determining a head address of the nth voice data in the data space, wherein the head address of the nth voice data is positioned behind a tail address of the (n-1) th voice data;
storing a first address of the nth voice data after a first address of the (n-1) th voice data in the directory space, and storing the nth voice data at the first address of the nth voice data;
after storing the voice data, calculating the number of the voice data stored in the voice file;
storing the number at a preset address of the directory space, wherein the number is used for judging whether the voice data is stored in the voice file or not according to the number when the voice data is read, and the preset address is a first address of the directory space;
receiving a deleting instruction for deleting the r-th voice data, wherein r is more than or equal to 1;
according to the deleting instruction, determining m + k (r-1) +1 byte to m + k (r-1) + k bytes in the directory space, and reading the head address of the r voice data from the k bytes;
deleting the r-th voice data stored in the data space according to the head address of the r-th voice data, and deleting the head address of the r-th voice data stored in the k bytes from the m + k (r-1) +1 byte to the m + k (r-1) + k byte;
when r is n, modifying the number of the strips;
and when r is less than n, modifying the number of the pieces, and recycling the storage space for storing the r-th voice data.
18. A voice file reading apparatus for reading voice data stored by the apparatus of claim 17, the apparatus comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to:
receiving a reading instruction for reading the s-th voice data stored in a voice file, wherein the voice file comprises a data space and a directory space, the head address of the data space is positioned behind the tail address of the directory space, the data space is used for storing the voice data, the directory space comprises a first space, a second space and a third space, the first space is used for storing the number of the voice data stored in the voice file, the second space is used for storing the head address of each piece of the voice data in the data space, the third space is used for writing the head address of the voice data, and s is larger than or equal to 1;
according to the reading instruction, determining the first address of the s-th voice data in the directory space;
reading the s-th voice data in the data space according to the initial address of the s-th voice data;
reading the number of pieces stored at a preset address of the directory space, wherein the number of pieces is the number of pieces of voice data stored in the voice file, the number of pieces is used for judging whether the voice data is stored in the voice file or not according to the number of pieces when the voice data is read, and the preset address is the first address of the directory space;
and when the s is less than or equal to the number, triggering and executing the step of determining the first address of the s-th voice data in the directory space.
CN201610618040.1A 2016-07-29 2016-07-29 Voice storage method, voice reading method and device Active CN107665173B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610618040.1A CN107665173B (en) 2016-07-29 2016-07-29 Voice storage method, voice reading method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610618040.1A CN107665173B (en) 2016-07-29 2016-07-29 Voice storage method, voice reading method and device

Publications (2)

Publication Number Publication Date
CN107665173A CN107665173A (en) 2018-02-06
CN107665173B true CN107665173B (en) 2021-05-14

Family

ID=61121985

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610618040.1A Active CN107665173B (en) 2016-07-29 2016-07-29 Voice storage method, voice reading method and device

Country Status (1)

Country Link
CN (1) CN107665173B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111159075B (en) * 2019-12-31 2021-11-05 成都海光微电子技术有限公司 Data transmission method and data transmission device

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06125384A (en) * 1992-10-09 1994-05-06 Uniden Corp Recording memory control method for telephone set
EP1001425A3 (en) * 1998-11-16 2001-08-29 L and G Kikaku Co., Ltd. Playback equipment
CN100389420C (en) * 2005-09-13 2008-05-21 北京中星微电子有限公司 Method and apparatus for accelerating file system operation by using coprocessor
CN100590676C (en) * 2008-05-30 2010-02-17 上海土锁网络科技有限公司 Network interaction voice toy components realization method
CN105843691B (en) * 2012-06-29 2020-04-10 北京奇虎科技有限公司 Method and device for interprocess communication in browser
CN104714860B (en) * 2013-12-16 2018-04-10 航天信息股份有限公司 A kind of cipher key backup device of invoice
CN104636140B (en) * 2015-01-29 2018-05-29 小米科技有限责任公司 Firmware compression method, firmware decompressing method and device

Also Published As

Publication number Publication date
CN107665173A (en) 2018-02-06

Similar Documents

Publication Publication Date Title
CN105845124B (en) Audio processing method and device
EP3176709A1 (en) Video categorization method and apparatus, computer program and recording medium
CN105786507B (en) Display interface switching method and device
CN106126025B (en) Interactive method and device for copying and pasting
WO2022142871A1 (en) Video recording method and apparatus
CN105511777B (en) Session display method and device on touch display screen
US20170090684A1 (en) Method and apparatus for processing information
CN104850643B (en) Picture comparison method and device
CN111767006B (en) Data processing method and device
CN111814088A (en) Page processing method and device
CN109783171B (en) Desktop plug-in switching method and device and storage medium
CN108984098B (en) Information display control method and device based on social software
US11600300B2 (en) Method and device for generating dynamic image
CN108153488B (en) Data self-adding method and device
US10225387B2 (en) Call processing method and device
CN106447747B (en) Image processing method and device
CN106919302B (en) Operation control method and device of mobile terminal
CN105957011B (en) Image processing method and device
CN107665173B (en) Voice storage method, voice reading method and device
CN107885464B (en) Data storage method, device and computer readable storage medium
CN106980781B (en) External equipment and control method and device of external equipment
CN113360708B (en) Video playing method and device, electronic equipment and storage medium
CN107967233B (en) Electronic work display method and device
CN106604088B (en) Method, device and equipment for processing data in buffer area
CN106897876B (en) Terminal payment processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant