An audio recording method, device, electronic equipment and readable storage medium
By managing microphone resources through an electronic control unit, the problem of audio focus contention when multiple applications record simultaneously is solved, enabling resource sharing and improving user experience while ensuring real-time performance and security.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GREAT WALL MOTOR CO LTD
- Filing Date
- 2024-12-24
- Publication Date
- 2026-05-12
AI Technical Summary
When multiple applications are recording simultaneously, they may compete for the microphone's audio focus, causing some applications to fail to wake up or record properly, thus affecting the user experience.
The electronic control unit determines the audio focus requirements of applications, allocates and manages microphone resources, so that applications that need audio focus can obtain microphone data first, and closes the recording permissions of other applications when necessary, ensuring real-time performance and security.
It enables resource sharing when multiple applications record simultaneously, improving user experience, ensuring real-time performance and security, and avoiding data loss and duplicate processing.
Smart Images

Figure CN119883176B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of speech technology, and more specifically, to a recording method, apparatus, electronic device, and readable storage medium in the field of speech technology. Background Technology
[0002] Currently, recording functions are present in various applications. If multiple applications record simultaneously, they may compete for microphone audio focus. For example, if a user needs to wake up a voice assistant while recording navigation, the voice assistant may fail to activate. Therefore, a method is urgently needed to ensure that multiple applications can record simultaneously, thereby improving the user experience. Summary of the Invention
[0003] This application provides a recording method, apparatus, electronic device, and readable storage medium, which enables multiple applications to record simultaneously.
[0004] Firstly, a recording method is provided, the method comprising:
[0005] If a recording request is received from the first application, and the microphone is turned on by the second application, then it is determined whether the first application is a first type of application that needs to occupy audio focus.
[0006] If the first application is a first-class application, then determine whether the second application is a second-class application that does not need to occupy audio focus;
[0007] If the second application is a second type of application, then the recording permission of the first application is enabled so that the first application and the second application can jointly obtain the audio data currently being collected by the microphone.
[0008] In this embodiment, when the electronic control unit receives a recording request from a first application that needs to occupy the audio focus, it determines whether the microphone is turned on by a second application that does not need to occupy the audio focus. If the microphone is turned on by the second application, the electronic control unit grants the first application recording permission so that the first application can obtain the audio data currently being collected by the microphone. Thus, after determining that the microphone is turned on by a second application that does not need to occupy the focus, the electronic control unit controls the granting of the first application's recording permission, allowing both the first and second applications to share the audio data collected by the microphone. This enables multiple applications to share microphone resources, thereby improving the user experience.
[0009] In conjunction with the first aspect, among some possible implementations, the method also includes:
[0010] Determine whether the first application requires exclusive microphone access to capture audio data;
[0011] If the first application needs exclusive access to the audio data captured by the microphone, then disable the recording permission of the second application so that the second application stops acquiring the audio data captured by the microphone.
[0012] In this embodiment, after receiving a recording request from the first application and determining that the microphone has been activated by the second application, the electronic control unit, if it determines that the first application needs exclusive access to the audio data collected by the microphone, disables the recording permission of the second application, thereby preventing the second application from acquiring the audio data collected by the microphone. Since voice calls have high security and real-time requirements, disabling the recording permission of the second application ensures that the first application can acquire the audio data collected by the microphone in real time, thus meeting the real-time requirements of voice calls. Simultaneously disabling the recording permissions of other applications reduces the risk of call information leakage.
[0013] In conjunction with the first aspect, in some possible implementations, the audio data captured by the microphone is stored in the target storage space. After disabling the recording permission of the second application, the method further includes:
[0014] Determine the first address; wherein, the first address is the address at which the second application reads audio data from the target storage space when the recording permission is closed;
[0015] Determine the second address; where the second address is the address at which the first application starts reading audio data from the target storage space when the recording permission is enabled;
[0016] Provide the second application with audio data located between the first and second addresses.
[0017] In this embodiment, after disabling the recording permission of the second application, the electronic control unit determines a first address and a second address; and provides the second application with audio data located between the first address and the second address. The audio data between the first address and the second address refers to audio data that the second application did not read before the recording permission was disabled. In this way, after disabling the recording permission of the second application, the second application will not immediately interrupt its service due to the closure of the recording permission, thus improving the overall performance and flexibility of the vehicle system.
[0018] In conjunction with the first aspect, in some possible implementations, providing audio data located between the first and second addresses to the second application includes:
[0019] After the recording permission of the first application is closed, the recording permission of the second application is reopened.
[0020] Provide the audio data located between the first and second addresses to the second application that has restarted recording permissions.
[0021] In this embodiment, after the recording permission of the first application is closed, the electronic control unit reopens the recording permission of the second application; and provides audio data located between the first address and the second address to the second application that has reopened its recording permission. Thus, after the recording permission of the first application is closed, the recording permission of the second application is reopened without the user needing to reopen the second application; furthermore, the second application can continue to process unread audio data, avoiding the loss and duplication of audio data.
[0022] In conjunction with the first aspect, in some possible implementations, the audio data captured by the microphone is stored in the target storage space. After granting recording permissions to the first application, the method also includes:
[0023] Determine the real-time read address when the first application reads audio data from the target storage space;
[0024] When there is a discrepancy between the real-time storage address and the real-time read address, the real-time read address is corrected based on the real-time storage address; where the real-time storage address is the address where the audio data currently being stored in the target storage space is located.
[0025] In this embodiment of the application, by correcting the real-time reading address when there is a deviation between the real-time storage address and the real-time reading address, it can be ensured that the read audio data is always close to the latest stored audio data, avoiding audio lag problems caused by reading delay, thereby improving the real-time experience of the application.
[0026] In conjunction with the first aspect, in some possible implementations, when there is a discrepancy between the real-time storage address and the real-time read address, the real-time read address is corrected based on the real-time storage address, including:
[0027] Determine the read speed when the first application reads audio data from the target storage space;
[0028] Determine the storage speed when storing audio data collected by the microphone into the target storage space;
[0029] When the storage speed is greater than the read speed and the real-time storage address is greater than the real-time read address, the real-time storage address will be used as the real-time read address.
[0030] In this embodiment of the application, when the real-time read address is much smaller than the real-time storage address, outdated data may be read, affecting the audio processing effect and real-time performance. By correcting the read address in a timely manner, it can be ensured that the read audio data is always up-to-date, avoiding the generation of invalid data, thereby improving the recording real-time performance and reliability of the application.
[0031] In conjunction with the first aspect, in some possible implementations, the target storage space is a ring-shaped storage space. When the storage speed is greater than the read speed and the real-time storage address is greater than the real-time read address, the real-time storage address is used as the real-time read address, including:
[0032] When the storage speed is greater than the reading speed, determine the number of storage overflows and reading overflows in the circular storage space after enabling the recording permission of the first application;
[0033] If the number of storage overflows is greater than the number of read overflows, and the real-time storage address is greater than the real-time read address, then the real-time storage address will be used as the real-time read address.
[0034] In this embodiment, when the storage speed is faster than the reading speed, the electronic control unit can determine whether the reading address needs to be corrected by comparing the number of storage overflows and the number of reading overflows. This effectively utilizes the storage space, ensures that the data is not overwritten due to the slow reading speed, and avoids the risk of memory waste and data loss.
[0035] In conjunction with the first aspect, some possible implementations include correcting the real-time read address based on the real-time storage address, including:
[0036] Determine the read speed when the first application reads audio data from the target storage space;
[0037] Determine the storage speed when storing audio data collected by the microphone into the target storage space;
[0038] When the read speed is greater than the storage speed, the waiting time is determined based on the speed difference between the read speed and the storage speed, and the first application is controlled to read audio data from the target storage space after waiting for the waiting time.
[0039] In this embodiment, after determining the reading speed and storage speed, if the reading speed is greater than the storage speed, the electronic control unit determines a waiting time based on the speed difference between the reading and storage speeds. The first application is then controlled to read audio data from the target storage space after waiting for the preset waiting time. Thus, if the reading speed is greater than the storage speed, the audio data may not have been completely written to the storage space. By setting a waiting time before reading, it can be ensured that the data is completely stored during the reading process, avoiding the reading of incomplete or inconsistent data, thereby guaranteeing the integrity and accuracy of the data.
[0040] Secondly, a recording device is provided, the device comprising:
[0041] The first determining module is used to determine whether the first application needs to occupy the audio focus if it determines that the microphone is turned on by the second application when it receives a recording request sent by the first application.
[0042] The second determining module is used to determine whether the second application needs to occupy audio focus if the first application needs to occupy audio focus.
[0043] The module enables the first application's recording permission if the second application does not need to occupy the audio focus, so that the first application can obtain the audio data currently being collected by the microphone.
[0044] Thirdly, an electronic device is provided, including a memory for storing executable program code;
[0045] A processor is used to call and run executable program code from memory, causing the electronic device to perform the method in any possible implementation of the first aspect described above.
[0046] Fourthly, an executable program code product is provided, comprising: executable program code that, when run on a computer, causes the computer to perform the method in any possible implementation of the first aspect described above.
[0047] Fifthly, a readable storage medium is provided that stores executable program code, which, when run on a computer, causes the computer to perform the method in any possible implementation of the first aspect described above. Attached Figure Description
[0048] Figure 1 This is a flowchart of the steps of a recording method provided in an embodiment of this application;
[0049] Figure 2 This is a schematic diagram of a ring-shaped storage space provided in an embodiment of this application;
[0050] Figure 3 This is a flowchart of the steps of a recording method provided in an embodiment of this application;
[0051] Figure 4 This is a schematic diagram of the structure of a recording device provided in an embodiment of this application;
[0052] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0053] The technical solutions in this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. "And / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0054] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.
[0055] Currently, with the continuous development of smart devices, recording functionality has become an indispensable part of many applications. However, when multiple applications use the microphone to record simultaneously, it can lead to audio focus contention issues. For example, while a user is inputting voice commands in a navigation app, they may also need to wake up a voice assistant to perform other tasks. In this situation, because both the navigation app and the voice assistant require audio focus, the voice assistant may fail to wake up successfully, impacting the user experience.
[0056] To address the aforementioned technical problems, this application provides a recording method that can be executed by an Electronic Control Unit (ECU) for controlling an audio system. Upon receiving a recording request from a first application that needs to occupy audio focus, the ECU determines whether the microphone is being used by a second application that does not need to occupy audio focus. If the microphone is being used by the second application, the ECU grants recording permission to the first application, allowing it to access the audio data currently being captured by the microphone. Thus, after determining that the microphone is being used by a second application that does not need to occupy audio focus, the ECU controls the granting of recording permission to the first application, enabling both the first and second applications to share the audio data captured by the microphone. This facilitates multiple applications sharing microphone resources, thereby improving the user experience.
[0057] See Figure 1 , Figure 1 This is a flowchart illustrating the steps of a recording method provided in an embodiment of this application. The executing entity of this method can be an electronic control unit, such as... Figure 1 As shown, the method may include the following steps.
[0058] S101, upon receiving a recording request from the first application, if the microphone is turned on by the second application, determine whether the first application is a first type of application that needs to occupy audio focus.
[0059] S102, if the first application is a first type of application, then determine whether the second application is a second type of application that does not need to occupy audio focus.
[0060] S103, if the second application is a second type of application, then enable the recording permission of the first application so that the first application and the second application can jointly obtain the audio data currently collected by the microphone.
[0061] The recording request refers to the request sent by the first application to request access to the microphone for recording.
[0062] Audio focus is used to manage the priority of multiple real-time applications during recording. For applications with high real-time requirements, such as real-time calls, users need to hear the other party's voice in real time, while their own voice also needs to be transmitted to the other party in real time. Therefore, high-real-time applications need to occupy audio focus to ensure that only one real-time application controls the microphone at a time. Conversely, for applications with lower real-time requirements, such as map navigation, the real-time requirements for audio are lower. These applications can tolerate some latency or interruptions, so they do not need to request audio focus. Even when sharing microphone resources with high-real-time applications, these applications will not have a significant impact on the user experience.
[0063] Taking vehicles as an example, during the R&D and design phase, developers can categorize applications in the in-vehicle system into four types: Category 1, Category 2, Category 3, and Category 4. Category 1 applications are high-real-time applications that require audio focus during recording and can share the microphone with other applications that do not. These include, but are not limited to, Voice over Internet Protocol (VoIP) and voice assistants. Category 2 applications are non-real-time applications that do not require audio focus during recording and can share the microphone with other applications. These include, but are not limited to, map navigation and multimedia playback. Category 3 applications are real-time applications that require audio focus during recording and do not share the microphone with other applications, including voice calls. Category 4 applications are non-real-time applications that do not require audio focus during recording and do not share the microphone with other applications.
[0064] For example, different types of applications have different needs and priorities regarding microphone resources. For the first type of application, such as VoIP, while it needs to occupy audio focus to ensure call continuity, it can share microphone resources with applications that don't require audio focus and have lower real-time requirements (such as map navigation). This is because while VoIP has some real-time requirements, it prioritizes call continuity and stability over completely monopolizing microphone resources. When sharing microphone resources with other applications, VoIP applications can handle potential interference through appropriate buffering and delay handling, thus maintaining call quality. For the second type of application, such as map navigation, microphone resources are typically only needed briefly at specific times (such as when the user inputs voice commands). Most of the time, it doesn't need to monopolize the microphone, so it can share microphone resources with other applications, improving resource utilization and allowing users to run multiple applications simultaneously without significant conflicts or performance degradation. For the third type of application (such as high-quality voice calls), dedicated microphone resources are required to ensure audio real-time performance and clarity. These applications have extremely high requirements for audio quality; any slight interference or delay can affect the user experience. In this situation, having exclusive microphone access can minimize external interference and ensure the integrity and clarity of the audio signal.
[0065] In one implementation, when the first application needs to record audio, it sends a recording request to the electronic control unit (ECU). Upon receiving the recording request, the ECU determines whether the microphone has been activated by the second application. If the microphone is activated by the second application, the ECU determines whether the first application needs to occupy audio focus. After determining that the first application needs to occupy audio focus, the ECU simultaneously determines whether the second application needs to occupy audio focus. If it determines that the second application does not need to occupy audio focus, the ECU can allocate audio focus to the first application and grant the first application recording permission, allowing the first application to acquire the audio data currently being captured by the microphone from the second application.
[0066] For example, taking a vehicle as an example, when the driver needs to make a VoIP call while the vehicle is in operation, they can send a recording request to the electronic control unit (ECU). Upon receiving the recording request, the ECU determines that the microphone is currently activated by the navigation system, meaning the driver is inputting voice commands to the navigation system via the microphone. Next, the ECU determines that the VoIP call requires audio focus for the call, while the navigation system does not require audio focus for recording. Therefore, the ECU can allocate audio focus to the VoIP call and grant it recording permissions, allowing it to access the audio data currently being collected by the microphone. This enables both the navigation system and the VoIP call to record simultaneously.
[0067] In another implementation, after receiving a recording request from the first application, the electronic control unit determines that the microphone has been activated by the second application. Then, the electronic control unit determines whether the first application needs to occupy the audio focus. After determining that the first application needs to occupy the audio focus, it simultaneously determines whether the second application needs to occupy the audio focus. If it is determined that the second application needs to occupy the audio focus, the electronic control unit can determine which application to allocate the audio focus to based on the priority of the first and second applications. For example, if the priority of the first application is higher than that of the second application, the recording permission of the second application is disabled, causing the second application to stop acquiring audio data from the microphone; simultaneously, the audio focus is allocated to the first application, and the recording permission of the first application is enabled.
[0068] In another implementation, after receiving a recording request from the first application, the electronic control unit determines whether the microphone has been turned on by the second application. If the electronic control unit determines that the microphone is not currently on, it determines whether the first application needs to occupy audio focus. If the first application needs to occupy audio focus, the electronic control unit allocates audio focus to the first application and grants the first application recording permission, allowing the first application to use the microphone to record.
[0069] Conversely, if the first application does not need to occupy the audio focus, the electronic control unit does not need to allocate the audio focus to the first application. Instead, it directly calls the recording interface to enable the first application's recording permission, allowing the first application to use the microphone for recording.
[0070] In another implementation, after receiving a recording request from the first application, the electronic control unit determines whether the microphone has been turned on by the second application. If the microphone is turned on by the second application, the electronic control unit determines whether the first application needs to occupy the audio focus. After determining that the first application does not need to occupy the audio focus, the electronic control unit can determine whether the second application needs to exclusively occupy the microphone's audio focus. If it is determined that the second application needs to exclusively occupy the microphone's audio focus, the first application is controlled to wait. After disabling the second application's recording permission and releasing the audio focus, the first application's recording permission is enabled. If it is determined that the second application does not need to exclusively occupy the microphone's audio focus, the first application's recording permission is directly enabled, allowing the first application to acquire the audio data of the second application currently being captured by the microphone.
[0071] In this embodiment, when the electronic control unit receives a recording request from a first application that needs to occupy the audio focus, it determines whether the microphone is turned on by a second application that does not need to occupy the audio focus. If the microphone is turned on by the second application that does not need to occupy the audio focus, the electronic control unit grants the first application recording permission so that the first application can obtain the audio data currently being collected by the microphone. Thus, after determining that the microphone is turned on by a second application that does not need to occupy the focus, the electronic control unit controls the granting of the first application's recording permission, allowing both the first and second applications to share the audio data collected by the microphone. This facilitates multiple applications sharing microphone resources, thereby improving the user experience.
[0072] Optionally, the recording method may also include the following steps.
[0073] Determine whether the first application requires exclusive microphone access to capture audio data;
[0074] If the first application needs exclusive access to the audio data captured by the microphone, then disable the recording permission of the second application so that the second application stops acquiring the audio data captured by the microphone.
[0075] In one implementation, after receiving a recording request from a first application and determining that the microphone has been turned on by a second application, the electronic control unit determines whether the first application is a third type of application that needs to exclusively access the audio data collected by the microphone. If the first application needs to exclusively access the audio data collected by the microphone, the electronic control unit disables the recording permission of the second application so that the second application stops acquiring the audio data collected by the microphone.
[0076] Furthermore, the electronic control unit assigns audio focus to the first application and enables the first application's recording permission, so that the first application can use the microphone to record.
[0077] For example, taking a vehicle as an example, when the driver is making a voice call while the vehicle is in operation, they can send a recording request to the electronic control unit (ECU). Upon receiving the request and confirming that the microphone is already activated by the map navigation system, the ECU determines that the voice call requires exclusive audio focus, i.e., exclusive access to the audio data captured by the microphone for the call. Therefore, the ECU disables the recording permission of the map navigation system, causing it to stop using the microphone. Further, the ECU can allocate audio focus to the voice call and enable its recording permission, thereby allowing the voice call to use the microphone.
[0078] In another implementation, after receiving a recording request from a first application and determining that the microphone has been activated by a second application, the electronic control unit determines whether the first application is a third type of application that requires exclusive access to the audio data captured by the microphone. If the first application requires exclusive access to the audio data captured by the microphone, it also determines whether the second application requires exclusive access to the audio data captured by the microphone. After determining that the second application requires exclusive access to the audio data captured by the microphone, the electronic control unit can determine which application to allocate audio focus to based on the priority of the first and second applications. For example, if the priority of the first application is higher than that of the second application, the recording permission of the second application is disabled to prevent it from acquiring audio data captured by the microphone; simultaneously, the audio focus is allocated to the first application, and the recording permission of the first application is enabled.
[0079] Conversely, if the first application needs exclusive access to the audio data captured by the microphone, and it is determined that the second application does not need exclusive access to the audio data captured by the microphone, the electronic control unit disables the recording permission of the second application so that the second application stops acquiring audio data captured by the microphone.
[0080] In this embodiment, after receiving a recording request from the first application and determining that the microphone has been activated by the second application, the electronic control unit, if it determines that the first application needs exclusive access to the audio data collected by the microphone, disables the recording permission of the second application, thereby preventing the second application from acquiring the audio data collected by the microphone. Since voice calls have high security and real-time requirements, disabling the recording permission of the second application ensures that the first application can acquire the audio data collected by the microphone in real time, thus meeting the real-time requirements of voice calls. Simultaneously disabling the recording permissions of other applications reduces the risk of call information leakage.
[0081] Optionally, the audio data captured by the microphone is stored in the target storage space. After disabling the recording permission of the second application, the method further includes:
[0082] Determine the first address; wherein, the first address is the address at which the second application reads audio data from the target storage space when the recording permission is closed;
[0083] Determine the second address; where the second address is the address at which the first application starts reading audio data from the target storage space when the recording permission is enabled;
[0084] Provide the second application with audio data located between the first and second addresses.
[0085] The target storage space refers to the storage space used to store the audio data captured by the microphone. The audio data between the first address and the second address refers to the audio data that the second application did not read when recording permissions were disabled.
[0086] In one implementation, after disabling the recording permission of the second application, the electronic control unit can determine a first address from the target storage space where the second application reads audio data when its recording permission is disabled. Further, after enabling the recording permission of the first application, it can determine a second address from the target storage space where the first application reads audio data. Then, the electronic control unit sends audio data between the first and second addresses to the second application, so that even after the recording permission of the second application is disabled, it can still retrieve audio data from the target storage space that the second application has not yet read.
[0087] For example, taking a vehicle as an example, during vehicle operation, the driver uses the in-vehicle navigation application for route planning, inputting destination information into the navigation application via voice commands. However, before the voice command input is completed, the navigation application's recording permission is disabled because the voice call had recording permission enabled. After the navigation application's recording permission is disabled, the electronic control unit (ECU) determines the location in the target storage space where the navigation application last read audio data, i.e., the first address. Then, after the voice call's recording permission is enabled, the ECU determines the location in the target storage space where the voice call began reading audio data, i.e., the second address. To ensure that the navigation application does not immediately interrupt service due to the closure of recording permission, the ECU can send audio data between the first and second addresses to the navigation application. In this way, the navigation application can continue processing the unread audio data, thereby completing the input of the destination information.
[0088] In this embodiment, after disabling the recording permission of the second application, the electronic control unit determines a first address and a second address; and provides the second application with audio data located between the first address and the second address. The audio data between the first address and the second address refers to audio data that the second application did not read before the recording permission was disabled. In this way, after disabling the recording permission of the second application, the second application will not immediately interrupt its service due to the closure of the recording permission, thus improving the overall performance and flexibility of the vehicle system.
[0089] Optionally, audio data located between the first and second addresses is provided to the second application, including:
[0090] After the recording permission of the first application is closed, the recording permission of the second application is reopened.
[0091] Provide the audio data located between the first and second addresses to the second application that has restarted recording permissions.
[0092] In this embodiment, after determining that the recording permission of the first application has been closed, the electronic control unit re-enables the recording permission of the second application; and provides the second application, which has re-enabled its recording permission, with audio data located between the first address and the second address.
[0093] For example, taking a vehicle as an example, during vehicle operation, if a voice call has recording permissions enabled, the navigation application's recording permissions need to be disabled. After the navigation application's recording permissions are disabled, the electronic control unit (ECU) determines and records both the first and second addresses. Then, after confirming that the first application's recording permissions are disabled, the ECU re-enables the navigation application's recording permissions and sends the audio data between the first and second addresses to the navigation application. This allows the navigation application to continue processing unread audio data, thereby completing the input of destination information.
[0094] In this embodiment, after the recording permission of the first application is closed, the electronic control unit reopens the recording permission of the second application; and provides audio data located between the first address and the second address to the second application that has reopened its recording permission. Thus, after the recording permission of the first application is closed, the recording permission of the second application is reopened without the user needing to reopen the second application; furthermore, the second application can continue to process unread audio data, avoiding the loss and duplication of audio data.
[0095] Optionally, the audio data captured by the microphone is stored in the target storage space. After granting recording permissions to the first application, the method further includes:
[0096] Determine the real-time read address when the first application reads audio data from the target storage space;
[0097] When there is a discrepancy between the real-time storage address and the real-time read address, the real-time read address is corrected based on the real-time storage address.
[0098] The real-time storage address is the address where the audio data currently stored in the target storage space is located; the real-time read address is the address where the audio data currently read from the target storage space is located.
[0099] In one implementation, the target storage space may include a storage pointer and a read pointer. After enabling recording permission for the first application, the electronic control unit uses a microphone to record audio data and stores the audio data captured by the microphone in the target storage space, determining the real-time storage address based on the storage pointer. The electronic control unit can read audio data from the target storage space and determine the real-time read address based on the read pointer. Then, the electronic control unit can compare the real-time storage address and the real-time read address. If there is a deviation between the real-time storage address and the real-time read address, and the deviation is greater than a preset deviation, then the real-time storage address is used as the real-time read address.
[0100] For example, suppose the preset deviation between the real-time storage address and the real-time read address is 50 bytes. After enabling the recording permission of the first application, the electronic control unit stores the audio data captured by the microphone in the target storage space and determines the real-time storage address to be 100 bytes. At the same time, it reads audio data from the target storage space and determines the real-time read address to be 20 bytes. The electronic control unit can calculate that the difference between the real-time storage address and the real-time read address is 80 bytes, which is greater than the preset deviation of 50 bytes, indicating that the reading speed is slow. Therefore, the real-time read address needs to be corrected. Thus, the real-time storage address of 100 bytes is used as the real-time read address, that is, the read pointer continues to read audio data from 100 bytes, and the audio data between the real-time storage address and the real-time read address is discarded.
[0101] In another example, the electronic control unit determines the real-time storage address to be 100 bytes. Simultaneously, it reads audio data from the target storage space and determines the real-time read address to be 60 bytes. The electronic control unit can calculate that the difference between the real-time storage address and the real-time read address is 40 bytes, which is less than the preset deviation of 50 bytes. Therefore, there is no need to correct the real-time read address; that is, the read pointer continues to read audio data from byte 60.
[0102] In another implementation, after determining the real-time storage address and the real-time read address, the electronic control unit determines the deviation between the real-time storage address and the real-time read address. If the deviation between the real-time storage address and the real-time read address is greater than a preset deviation, and the real-time storage address precedes the real-time read address (i.e., the real-time storage address is greater than the real-time read address), then the real-time storage address is used as the real-time read address.
[0103] In this embodiment, after enabling recording permission for the first application, the electronic control unit determines the real-time read address and real-time storage address when the first application reads audio data. If there is a discrepancy between the real-time storage address and the real-time read address, the real-time storage address is used as the real-time read address. In this way, by correcting the real-time read address when there is a discrepancy between the real-time storage address and the real-time read address, it can be ensured that the read audio data is always close to the latest stored audio data, avoiding audio lag problems caused by read delays, thereby improving the real-time experience of the application.
[0104] Optionally, when there is a discrepancy between the real-time storage address and the real-time read address, the real-time read address is corrected based on the real-time storage address, including:
[0105] Determine the read speed when the first application reads audio data from the target storage space;
[0106] Determine the storage speed when storing audio data collected by the microphone into the target storage space;
[0107] When the storage speed is greater than the read speed and the real-time storage address is greater than the real-time read address, the real-time storage address will be used as the real-time read address.
[0108] The read speed refers to the rate at which the first application reads audio data from the target storage space, usually expressed in bytes per second. The storage speed refers to the rate at which the audio data captured by the microphone is written to the target storage space, usually expressed in bytes per second.
[0109] In one implementation, after determining that there is a discrepancy between the real-time storage address and the real-time read address, the electronic control unit can determine the read speed when the first application reads audio data from the target storage space; simultaneously, it can determine the storage speed when storing audio data collected by the microphone into the target storage space. Then, the electronic control unit can compare the read speed and the storage speed. If the storage speed is greater than the read speed and the real-time storage address is greater than the real-time read address, then the real-time storage address is used as the real-time read address.
[0110] For example, assume that the real-time storage address and real-time read address were both 0 at the previous moment; at the current moment, the electronic control unit determines that the storage speed for storing audio data collected by the microphone into the target storage space is 100 bytes / second; that is, the real-time storage address is 100 bytes. The electronic control unit determines that the read speed for the first application to read audio data from the target storage space is 60 bytes / second; that is, the real-time read address is 60 bytes. Subsequently, if the electronic control unit determines that the storage speed is greater than the read speed and the real-time storage address is greater than the real-time read address, it indicates that the read speed is too slow, and the real-time read address needs to be corrected. The real-time storage address of 100 bytes is used as the real-time read address, that is, the read pointer continues to read audio data from 100 bytes, and the audio data between the real-time storage address and the real-time read address is discarded.
[0111] In another implementation, after determining that there is a deviation between the real-time storage address and the real-time read address, the electronic control unit can determine the read speed when the first application reads audio data from the target storage space; simultaneously, it can determine the storage speed when storing audio data collected by the microphone in the target storage space. Then, the electronic control unit can compare the read speed and the storage speed to determine whether the storage speed is greater than the read speed, and whether the difference between the storage speed and the read speed is greater than a preset speed difference; further, the electronic control unit can determine whether the deviation between the real-time storage address and the real-time read address is greater than a preset deviation. If the difference between the storage speed and the read speed is greater than the preset speed difference, and the deviation between the real-time storage address and the real-time read address is greater than the preset deviation, then the real-time storage address is used as the real-time read address.
[0112] For example, the preset deviation is 80 bytes; the preset speed difference is 50 bytes / second; assuming the previous real-time storage address was 100 bytes and the real-time read address was 60 bytes; at the current moment, the electronic control unit determines that the storage speed for storing the audio data collected by the microphone into the target storage space is 100 bytes / second; that is, the real-time storage address is 200 bytes. The electronic control unit determines that the read speed for the first application reading audio data from the target storage space is 40 bytes / second; that is, the real-time read address is 100 bytes. Then, the electronic control unit determines that the deviation between the current real-time storage address and the real-time read address is 100 bytes, which is greater than the preset deviation of 80 bytes. Furthermore, the difference between the storage speed and the read speed is 60 bytes / second, which is greater than the preset speed difference of 50 bytes / second. Therefore, the electronic control unit needs to correct the real-time read address, using the real-time storage address of 200 bytes as the real-time read address; that is, the read pointer continues to read audio data from byte 200, and the audio data between the real-time storage address of 200 bytes and the real-time read address of 100 bytes is discarded.
[0113] In this embodiment, the electronic control unit can determine the reading speed and the storage speed; and when the storage speed is greater than the reading speed and the real-time storage address is greater than the real-time reading address, the real-time storage address is used as the real-time reading address. Thus, when the real-time reading address is significantly smaller than the real-time storage address, outdated data may be read, affecting the audio processing effect and real-time performance. By promptly correcting the reading address, it can be ensured that the read audio data is always up-to-date, avoiding the generation of invalid data, thereby improving the recording real-time performance and reliability of the application.
[0114] Optionally, the target storage space is a ring-shaped storage space. When the storage speed is greater than the read speed and the real-time storage address is greater than the real-time read address, the real-time storage address is used as the real-time read address, including:
[0115] When the storage speed is greater than the reading speed, determine the number of storage overflows and reading overflows in the circular storage space after enabling the recording permission of the first application;
[0116] If the number of storage overflows is greater than the number of read overflows, and the real-time storage address is greater than the real-time read address, then the real-time storage address will be used as the real-time read address.
[0117] Among them, circular storage space refers to a circular storage structure with the first and last data connected. It can store audio data in a fixed-size space. When the storage space is full, new data will overwrite the oldest data, and so on in a circular manner.
[0118] Storage overflow count refers to the number of times the real-time storage address passes through the starting address of the circular storage space, that is, the number of times old data is overwritten when new data is written. Read overflow count refers to the number of times the real-time read address passes through the starting address of the circular storage space.
[0119] See Figure 2 , Figure 2 This is a schematic diagram of a ring-shaped storage space provided in an embodiment of this application. The storage spaces are arranged in a ring shape, connected end to end, forming a loop structure. With a fixed size, the ring-shaped storage space reuses storage resources by overwriting old data. For example, a storage pointer A indicates the storage location of audio data and moves continuously as data is written. When storage pointer A reaches the ring-shaped storage space boundary B, it automatically resets to the starting position, realizing cyclic writing, and the storage overflow count is incremented by 1. A read pointer H indicates the reading location of audio data and moves continuously as data is read. When read pointer H reaches the ring-shaped storage space boundary B, it also resets to the starting position, realizing cyclic reading, and the read overflow count is incremented by 1.
[0120] Audio data is captured by the microphone and stored in a circular storage space. The storage operation is controlled by the storage pointer A. When the application needs to process audio data, it starts reading from the position indicated by the read pointer H. The read operation is controlled by the read pointer H. When the storage pointer A is greater than the read pointer H, it indicates that the audio data is backlogged. The reading progress can be adjusted by correcting the pointer H.
[0121] During the R&D design phase, researchers can rationally design the size of the ring-shaped storage space according to actual needs, thereby avoiding excessive memory consumption and achieving efficient reuse. For example, researchers can calculate the amount of audio data that needs to be stored per second using audio parameters, which may include, but are not limited to, sampling rate, number of channels, and bit depth. For instance, if the sampling rate is 16000, with a single channel and a bit depth of 16 bits, then the amount of audio data that needs to be stored per second is 32000 bytes (32KB). If the sampling rate is 48000, with dual channels and a bit depth of 16 bits, then the amount of audio data that needs to be stored per second is 192000 bytes (192KB). Therefore, the ring-shaped storage space can be designed to store approximately 30 seconds of audio data, with a data volume ranging from 937.5KB to 5625KB. The specific size can be adjusted according to actual needs and is not limited thereto.
[0122] In this embodiment, when the electronic control unit determines that the storage speed is greater than the reading speed, it can determine the number of storage overflows and reading overflows in the circular storage space after enabling the recording permission of the first application. Then, the electronic control unit can compare the number of storage overflows and reading overflows. If the number of storage overflows is greater than the number of reading overflows, and the real-time storage address is greater than the real-time reading address, the real-time storage address is used as the real-time reading address.
[0123] For example, after determining that the storage speed is greater than the reading speed, the electronic control unit (ECU) starts monitoring the number of storage overflows and reading overflows after activating the recording permission of the first application. Assuming that at the current moment, the ECU determines that the number of storage overflows is 2 and the number of reading overflows is 0, meaning that storage pointer A has crossed the circular storage space boundary twice and reading pointer H has crossed the circular storage space boundary 0 times, indicating that the data reading speed is slow, and the real-time storage address of 200 bytes is greater than the real-time reading address of 50 bytes, the ECU will correct the real-time reading address, using the real-time storage address of 200 bytes as the real-time reading address. That is, the reading pointer continues to read audio data from byte 200, and the audio data between the real-time storage address of 200 bytes and the real-time reading address of 50 bytes is discarded.
[0124] In this embodiment, when the storage speed is greater than the reading speed, the electronic control unit determines the number of storage overflows and reading overflows in the circular storage space after enabling the recording permission of the first application. If the number of storage overflows is greater than the number of reading overflows, and the real-time storage address is greater than the real-time reading address, the real-time storage address is used as the real-time reading address. Thus, when the storage speed is faster than the reading speed, the electronic control unit can determine whether to correct the reading address by comparing the number of storage overflows and the number of reading overflows, thereby effectively utilizing the storage space and ensuring that data is not overwritten due to slow reading speed, avoiding the risk of memory waste and data loss.
[0125] Optionally, the real-time read address is corrected based on the real-time storage address, including:
[0126] Determine the read speed when the first application reads audio data from the target storage space;
[0127] Determine the storage speed when storing audio data collected by the microphone into the target storage space;
[0128] When the read speed is greater than the storage speed, the waiting time is determined based on the speed difference between the read speed and the storage speed, and the first application is controlled to read audio data from the target storage space after waiting for the waiting time.
[0129] The waiting time is directly proportional to the speed difference between the read speed and the storage speed.
[0130] In one embodiment, the electronic control unit can periodically determine the read speed and storage speed according to a preset duration, compare the read speed and storage speed, and calculate the speed difference between the read speed and storage speed when the read speed is greater than the storage speed. Then, the electronic control unit can determine a target difference range from a set of preset difference ranges, where each of the multiple difference ranges corresponds to a different waiting time. Based on the preset waiting time corresponding to the target difference range, the electronic control unit can control the first application to read audio data from the target storage space after waiting for the preset waiting time.
[0131] Developers can pre-configure multiple difference ranges and pre-configure the corresponding waiting time for each difference range for the vehicle. For example, when the speed difference between read and write speeds is greater than 10 bytes / second and less than 30 bytes / second, the current speed difference is determined to be the first difference range; when the speed difference is greater than or equal to 30 bytes / second and less than or equal to 60 bytes / second, the current speed difference is determined to be the second difference range; and when the speed difference is greater than 60 bytes / second, the current speed difference is determined to be the third difference range. Furthermore, when the speed difference is in the first difference range, the waiting time is determined to be 10ms; when the speed difference is in the second difference range, the waiting time is determined to be 15ms; and when the speed difference is in the third difference range, the waiting time is determined to be 20ms.
[0132] For example, the electronic control unit determines that the read speed is 100 bytes / second and the storage speed is 50 bytes / second, compares the read speed and storage speed, determines that the read speed is greater than the storage speed, and calculates the speed difference between the read speed and storage speed as 50 bytes / second, defining the current speed difference as the second difference interval; simultaneously, it determines that the waiting time corresponding to the second difference interval is 15ms. Then, the electronic control unit can control the first application to read audio data from the target storage space after waiting for 15ms.
[0133] It should be noted that researchers can determine the waiting time for the first application based on pre-set experiments, and there are no restrictions on comparisons.
[0134] In this embodiment, after determining the reading speed and storage speed, if the reading speed is greater than the storage speed, the electronic control unit determines a waiting time based on the speed difference between the reading speed and the storage speed, and controls the first application to read audio data from the target storage space after waiting for the preset waiting time. Thus, if the reading speed is greater than the storage speed, the audio data may not have been completely written to the storage space. By setting a waiting time before reading, it can be ensured that the data is completely stored before reading, avoiding the reading of incomplete or inconsistent data, thereby guaranteeing the integrity and accuracy of the audio data.
[0135] See Figure 3 , Figure 3 This is a flowchart illustrating the steps of a recording method provided in an embodiment of this application, as follows: Figure 3 As shown, the method may include the following steps.
[0136] S301 receives a recording request sent by the first application.
[0137] S302, determine whether the microphone is turned on by the second application. If yes, proceed to step S303; otherwise, proceed to step S307.
[0138] S303, determine whether the first application needs to occupy the audio focus; if yes, proceed to step S304; otherwise, proceed to step S307.
[0139] S304, determine whether the first application needs exclusive access to the microphone to collect audio data; if yes, proceed to step S305; otherwise, proceed to step S306.
[0140] S305, disable recording permissions for the second application.
[0141] The electronic control unit can disable the recording permission of the second application, thereby preventing the second application from acquiring audio data collected by the microphone.
[0142] S306, determine whether the second application needs to occupy the audio focus; if yes, proceed to step S308; otherwise, proceed to step S307.
[0143] S307, grant recording permission to the first application.
[0144] After enabling the recording permission of the first application, the electronic control unit can enable the first application to obtain the audio data currently being collected by the microphone.
[0145] S308, after disabling the recording permission of the second application, assigns audio focus to the first application and enables the recording permission of the first application.
[0146] It should be noted that the implementation methods and technical effects of each step in the embodiments of this application can be referred to the relevant content in the above embodiments, and will not be repeated here.
[0147] See Figure 4 , Figure 4 This is a schematic diagram of the structure of a recording device provided in an embodiment of this application. The recording device can be disposed in an electronic control unit and may include: a first determining module 401, a second determining module 402 and an opening module 403.
[0148] The first determining module 401 is used to determine whether the first application is a first type of application that needs to occupy audio focus if the microphone is turned on by the second application when a recording request is received from the first application.
[0149] The second determining module 402 is used to determine whether the second application is a second type of application that does not need to occupy audio focus if the first application is a first type of application.
[0150] The enabling module 403 is used to enable the recording permission of the first application if the second application is a second type of application, so that the first application and the second application can jointly obtain the audio data currently collected by the microphone.
[0151] Optionally, the recording device further includes: a third determining module and a closing module;
[0152] The third determining module is used to determine whether the first application needs to exclusively use the microphone to collect audio data;
[0153] The closing module is used to disable the recording permission of the second application if the first application needs exclusive access to the audio data captured by the microphone, so that the second application stops acquiring the audio data captured by the microphone.
[0154] Optionally, the audio data collected by the microphone is stored in the target storage space, and the closing module is specifically used to determine the first address; wherein the first address is the address at which the second application reads audio data from the target storage space when the recording permission is closed; determine the second address; wherein the second address is the address at which the first application starts reading audio data from the target storage space when the recording permission is enabled; and provide the second application with audio data located between the first address and the second address.
[0155] Optionally, the closing module is specifically used to re-enable the recording permission of the second application after the recording permission of the first application is closed; and to provide the second application, which has re-enabled its recording permission, with audio data located between the first address and the second address.
[0156] Optionally, the audio data collected by the microphone is stored in the target storage space. The enabling module 403 is specifically used to determine the real-time reading address when the first application reads audio data from the target storage space; when there is a deviation between the real-time storage address and the real-time reading address, the real-time reading address is corrected according to the real-time storage address; wherein, the real-time storage address is the address where the audio data currently stored in the target storage space is located.
[0157] Optionally, the enabling module 403 is specifically used to determine the reading speed when the first application reads audio data from the target storage space; determine the storage speed when storing audio data collected by the microphone in the target storage space; and use the real-time storage address as the real-time reading address when the storage speed is greater than the reading speed and the real-time storage address is greater than the real-time reading address.
[0158] Optionally, the target storage space is a ring-shaped storage space. The enabling module 403 is specifically used to determine the number of storage overflows and the number of read overflows in the ring-shaped storage space after enabling the recording permission of the first application when the storage speed is greater than the reading speed. If the number of storage overflows is greater than the number of read overflows and the real-time storage address is greater than the real-time reading address, the real-time storage address is used as the real-time reading address.
[0159] Optionally, the enabling module 403 is specifically used to determine the reading speed when the first application reads audio data from the target storage space; determine the storage speed when storing audio data collected by the microphone in the target storage space; when the reading speed is greater than the storage speed, determine the waiting time based on the speed difference between the reading speed and the storage speed, and control the first application to read audio data from the target storage space after the waiting time.
[0160] The recording device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, so it will not be described again here.
[0161] See Figure 5 , Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0162] For example, such as Figure 5 As shown, the vehicle 500 includes a memory 501 and a processor 502. The memory 501 stores executable program code 5011, and the processor 502 is used to call and execute the executable program code 5011 to perform a recording method.
[0163] Furthermore, this application also protects a vehicle that may include a memory and a processor, wherein the memory stores executable program code, and the processor is used to call and execute the executable program code to perform a recording method provided in this application.
[0164] This embodiment also provides a readable storage medium storing executable program code. When the executable program code is run on a computer, the computer performs the aforementioned method steps to implement the recording method provided in the above embodiment.
[0165] This embodiment also provides an executable program code product. When the executable program code product is run on a computer, the computer performs the above-mentioned related steps to implement the recording method provided in the above embodiment.
[0166] In this embodiment, the device, readable storage medium, executable program code product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding methods provided above, and will not be repeated here.
[0167] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0168] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0169] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A recording method, characterized in that, The method includes: If a recording request is received from the first application, and the microphone is turned on by the second application, then it is determined whether the first application is a first type of application that needs to occupy audio focus. If the first application is a first type of application, then determine whether the second application is a second type of application that does not need to occupy the audio focus; If the second application is the second type of application, then the recording permission of the first application is enabled so that the first application and the second application can jointly obtain the audio data currently collected by the microphone; Determine whether the first application needs exclusive access to the audio data captured by the microphone; If the first application needs to exclusively access the audio data collected by the microphone, then the recording permission of the second application is disabled so that the second application stops acquiring the audio data collected by the microphone, and the audio data collected by the microphone is stored in the target storage space. After disabling the recording permission of the second application, determine the first address; wherein, the first address is the address at which the second application reads audio data from the target storage space when the recording permission is disabled; determine the second address; wherein, the second address is the address at which the first application starts reading audio data from the target storage space when the recording permission is enabled; After the recording permission of the first application is closed, the recording permission of the second application is reopened; audio data located between the first address and the second address is provided to the second application that has reopened its recording permission.
2. The method according to claim 1, characterized in that, The audio data captured by the microphone is stored in the target storage space. After granting recording permission to the first application, the method further includes: Determine the real-time read address when the first application reads audio data from the target storage space; When there is a deviation between the real-time storage address and the real-time read address, the real-time read address is corrected according to the real-time storage address; wherein, the real-time storage address is the address where the audio data stored in the target storage space is located at the current moment.
3. The method according to claim 2, characterized in that, When there is a deviation between the real-time storage address and the real-time read address, correcting the real-time read address based on the real-time storage address includes: Determine the reading speed of the first application when reading audio data from the target storage space; Determine the storage speed when storing the audio data collected by the microphone into the target storage space; When the storage speed is greater than the reading speed and the real-time storage address is greater than the real-time reading address, the real-time storage address is used as the real-time reading address.
4. The method according to claim 3, characterized in that, The target storage space is a ring-shaped storage space. The step of using the real-time storage address as the real-time read address when the storage speed is greater than the read speed and the real-time storage address is greater than the real-time read address includes: If the storage speed is greater than the reading speed, determine the number of storage overflows and reading overflows of the annular storage space after enabling the recording permission of the first application; If the number of storage overflows is greater than the number of read overflows, and the real-time storage address is greater than the real-time read address, then the real-time storage address shall be used as the real-time read address.
5. The method according to claim 2, characterized in that, The step of correcting the real-time read address based on the real-time storage address includes: Determine the reading speed of the first application when reading audio data from the target storage space; Determine the storage speed when storing the audio data collected by the microphone into the target storage space; When the reading speed is greater than the storage speed, a waiting time is determined based on the speed difference between the reading speed and the storage speed, and the first application is controlled to read audio data from the target storage space after waiting for the waiting time.
6. A recording device, characterized in that, The device includes: The first determining module is used to determine whether the first application is a first type of application that needs to occupy audio focus if the microphone is turned on by the second application when a recording request is received from the first application. The second determining module is used to determine whether the second application is a second type of application that does not need to occupy the audio focus if the first application is the first type of application; The module is configured to enable the recording permission of the first application if the second application is a second type of application, so that the first application and the second application can jointly obtain the audio data currently collected by the microphone. The third determining module is used to determine whether the first application needs to exclusively access the audio data collected by the microphone; The closing module is used to close the recording permission of the second application if the first application needs to exclusively access the audio data collected by the microphone, so that the second application stops acquiring the audio data collected by the microphone, and the audio data collected by the microphone is stored in the target storage space. The closing module is specifically used to: determine a first address after closing the recording permission of the second application; wherein the first address is the address at which the second application reads audio data from the target storage space when the recording permission is closed; determine a second address; wherein the second address is the address at which the first application starts reading audio data from the target storage space when the recording permission is enabled; re-enable the recording permission of the second application after the recording permission of the first application is closed; and provide audio data located between the first address and the second address to the second application that has re-enabled its recording permission.
7. An electronic device, characterized in that, The electronic device includes: Memory, used to store executable program code; A processor for calling and running the executable program code from the memory, causing the electronic device to perform the method as described in any one of claims 1 to 5.