Disclosure of Invention
The disclosure aims to provide a method, a device, a storage medium and an electronic device for voice broadcast notification, so as to solve the problem that the voice broadcast notification cannot be performed under the condition that an application program is completely closed.
In order to achieve the above object, a first aspect of the present disclosure provides a method for broadcasting a notification in voice, which is applied to a terminal and includes:
aiming at a notification sent by an application server to a target application program in a closed state on the terminal, acquiring a broadcast text of the notification;
decomposing the broadcast text into a plurality of target character segments, wherein one target character segment at least comprises one character;
selecting a plurality of target voice fragments corresponding to the target character fragments one by one from a preset voice fragment library according to a first corresponding relation between the character fragments and the voice fragments;
and combining the target voice fragments into broadcast audio to be played according to the sequence of the target character fragments in the broadcast text.
Optionally, the obtaining of the broadcasted text of the notification includes:
determining a target notification extended text corresponding to the target notification type parameter according to the target notification type parameter of the notification and a second corresponding relation between the notification type parameter of the target application program and the notification extended text;
and composing the text content of the notification and the target notification extension text into the broadcast text.
Optionally, the preset speech segment library is stored in a storage path of the target application program.
Optionally, the data sharing space APP Groups of the application program of the terminal includes the target application program and a preset ServiceExtension class, the ServiceExtension class includes a didReceiveNotifacationRequest method, and the ServiceExtension class can intercept the notification sent by the application server in the data sharing space by the didReceiveNotifacationRequest method, and execute the method step of acquiring the broadcast text of the notification for the notification until the target voice fragments are combined into a broadcast audio for playing.
Optionally, the voice clip library stores a playing duration of each voice clip, and the combining of the plurality of target voice clips into an broadcast audio for playing according to the sequence of the plurality of target character clips in the broadcast text includes:
setting an initial playing time;
sequencing the target voice fragments according to the sequence of the target character fragments in the broadcast text, and determining the starting playing time of each target voice fragment according to the initial playing time and the sum of the playing durations of all target voice fragments before the target voice fragment in the sequencing;
and combining the target voice segments into broadcast audio to be played according to the initial playing time and the starting playing time of each target voice segment.
The second aspect of the present disclosure further provides a device for voice broadcast notification, which is applied to a terminal, and includes:
the terminal comprises an acquisition module, a broadcast module and a broadcast module, wherein the acquisition module is used for acquiring a broadcast text of a notification which is sent to a target application program in a closed state on the terminal by an application server;
the decomposition module is used for decomposing the broadcast text into a plurality of target character segments, and each target character segment at least comprises one character;
the corresponding module is used for selecting a plurality of target voice fragments which are in one-to-one correspondence with the target character fragments from a preset voice fragment library according to a first corresponding relation between the character fragments and the voice fragments;
and the playing module is used for combining the target voice fragments into broadcast audio to play according to the sequence of the target character fragments in the broadcast text.
The third aspect of the present disclosure also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of any one of the above first aspects.
A fourth aspect of the present disclosure also provides an electronic device, including:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the method of any of the first aspects above.
Through the technical scheme, the following technical effects can be at least achieved:
the method comprises the steps that a notification sent to a target application program in a closed state on a terminal by an application server is acquired, a broadcast text of the notification is divided into a plurality of target character segments, then a plurality of target voice segments corresponding to the target character segments one by one are selected from a preset voice segment library according to a first corresponding relation between the character segments and the voice segments, and finally the target voice segments are combined into broadcast audio to be played according to the sequence of the target character segments in the broadcast text. By the method, the voice broadcast notification is carried out, and the problem that the voice broadcast notification cannot be carried out under the condition that the application program is completely closed is solved.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect. The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units. In addition, references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and one skilled in the art will appreciate that "one or more" will be understood unless the context clearly dictates otherwise.
As background art shows, when a message is received, an application program needs to be in an active state to perform voice broadcast through a user terminal in time, for example, the application program runs in front of or in the background of the user terminal. In most cases, the application may not be active at all times. Unonotificationserviceextension is a new characteristic after the promotion of the IOS10, as shown in fig. 1, an original application server pushes a notification to a terminal device through an Apple Push Notification Service (APNs), the notification is pushed from the APNs to a user mobile phone, an optional step, namely ServiceExtension processing, is added in the middle, and through the ServiceExtension processing, the notification content to be shown to a user can be realized to be processed in various customizations, and finally, a richer notification is presented to the user. In the related art, when the application is completely closed, the function for playing the voice in ServiceExtension is directly used to process the notification and perform the voice broadcast, but after the IOS12.1, the function is closed, and when the application is completely closed, the voice broadcast notification cannot be performed.
The embodiment of the disclosure provides a method and a device for voice broadcast notification, a storage medium and an electronic device, so as to solve the problem that the voice broadcast notification cannot be performed under the condition that an application program is completely closed.
Before introducing the method, the apparatus, the storage medium, and the electronic device for voice broadcast notification of the present disclosure, an application scenario of the present disclosure is introduced first, and each embodiment provided by the present disclosure is applicable to an application program in a closed state on a terminal device, where the closed state refers to a state where the application program is completely closed, that is, a process is killed. In addition, the terminal devices may be, for example, a mobile phone, a tablet computer, and the like, which is not limited in this disclosure.
The embodiment of the present disclosure provides a method for voice broadcast notification, as shown in fig. 2, which is applied to a terminal, and the method includes:
s201, aiming at a notification sent by an application server to a target application program in a closed state on the terminal, acquiring a broadcast text of the notification.
S202, decomposing the broadcast text into a plurality of target character segments, wherein one target character segment at least comprises one character.
S203, selecting a plurality of target voice fragments corresponding to the target character fragments one by one in a preset voice fragment library according to the first corresponding relation between the character fragments and the voice fragments.
And S204, combining the target voice fragments into broadcast audio for playing according to the sequence of the target character fragments in the broadcast text.
By adopting the method, aiming at the notification sent by the application server to the target application program in the closed state on the terminal, the broadcast text of the notification is obtained and decomposed into a plurality of target character segments, then a plurality of target voice segments corresponding to the target character segments one by one are selected from a preset voice segment library according to the first corresponding relation between the character segments and the voice segments, and finally the target voice segments are combined into the broadcast audio for playing according to the sequence of the target character segments in the broadcast text. By the method, the voice broadcast notification is carried out, and the problem that the voice broadcast notification cannot be carried out under the condition that the application program is completely closed is solved.
In order to make the method provided by the embodiment of the present disclosure more easily understood by those skilled in the art, the method steps described above in fig. 2 are explained in detail below.
In a possible implementation manner, the obtaining of the broadcasted text of the notification in step S201 may include: and determining a target notification extended text corresponding to the target notification type parameter according to the target notification type parameter of the notification and a second corresponding relation between the notification type parameter of the target application program and the notification extended text, and forming the broadcast text by the text content of the notification and the target notification extended text.
Optionally, the above-mentioned obtaining of the broadcast text may be performed at a terminal, or may be performed at an application server, and the terminal directly receives the broadcast text, which is not specifically limited by the present disclosure.
Illustratively, an application of a certain payment type is in a closed state on the terminal, and the application server sends a notification to the application, the target notification type parameter of the notification being "new transaction is account," and the text content being "123231.21". The notification expansion text corresponding to the target notification type parameter is that "you have a new transaction to account", the text content is the amount of money, and the finally obtained broadcast text is that "you have a new transaction to account, twelve thousand three thousand twenty-hundred thirty-one-half-one-yuan". 15 target character fragments are obtained after decomposition: "you have a new transaction to account, 3, 2, 1, ten, thousand, hundred, ten, dot, yuan". By adding the notification extension text, the content of the notification can be enriched.
In a possible implementation manner, the preset voice segment library in step S203 is stored in the storage path of the target application program, so as to reduce the time for matching the voice segment, and avoid failure of voice broadcast notification due to timeout.
Illustratively, according to the first corresponding relationship between the character segments and the voice segments, 15 target voice segments corresponding to 15 target character segments one by one are selected from a preset voice segment library: "you have a new transaction to account, 3, 2, 1, ten, thousand, hundred, ten, dot, yuan".
In a possible implementation manner, the voice clip library stores a playing time length of each voice clip, and step S204 may include: setting an initial playing time; then, sequencing the target voice segments according to the sequence of the target character segments in the broadcast text, and determining the starting playing time of each target voice segment according to the initial playing time and the sum of the playing durations of all the target voice segments before the target voice segment in the sequencing; and finally combining the target voice segments into broadcast audio to be played according to the initial playing time and the starting playing time of each target voice segment.
Illustratively, the 15 target voice segments are sorted according to the sequence of the 15 target character segments obtained in the above steps in the broadcast text, and the obtained sequence is "you have a new transaction account, ten, 2, ten, 3, thousand, 2, hundred, 3, ten, 1, dot, 2, 1, and yuan". Assuming that the playing time of the voice segment "you have a new transaction arrive at the account" is 5 seconds, the playing time of the voice segments of other single characters is 0.5 seconds, the initial playing time is "10 o 35 min 02 s", the playing time of the first target voice segment is "10 o 35 min 02 s", the playing time of the second target voice segment is "10 o 35 min 07 s", and so on, the 15 target voice segments are combined into broadcast audio for playing.
In a possible implementation manner, the data shared space (APP Groups) of the application program of the terminal includes the target application program and a preset ServiceExtension class, the ServiceExtension class includes a dideceivenotifacationrequest method, and the ServiceExtension class can intercept the notification sent by the application server in the data shared space by the dideceivenotifacationrequest method and execute the method steps from S201 to S204 for the notification.
Optionally, a ServiceExtension class is created, then a didreceivenotificationrequest method is added to the class, the method can intercept and modify the notification, and finally the ServiceExtension class and the target application are added to a data sharing space (APP Groups) for configuration, so that data sharing between the ServiceExtension class and the target application is realized. Thus, when the target application receives a notification, the ServiceExtension class may also receive the notification.
In order to make the method provided by the embodiment of the present disclosure easier to understand by those skilled in the art, the following describes the method steps of the voice broadcast notification provided by the embodiment of the present disclosure in detail. As shown in fig. 3, the method includes:
s301, creating a ServiceExtension class, and adding a didReceiveNotificationRequest method in the class.
S302, adding the ServiceExtension class and the target application program into a data sharing space (APP Groups) for configuration.
S303, the application server sends a notice to the target application program.
And S304, judging whether the target application program is in a complete closing state.
Further, in the case where the target application is in the completely closed state, step S305 is executed.
S305, the ServiceExtension intercepts the notification by calling a didReceiveNotifacationRequest method, acquires the broadcast text of the notification, and decomposes the broadcast text into a plurality of target character fragments.
S306, selecting a plurality of target voice fragments corresponding to the target character fragments one by one in a voice fragment library of an application program through an APP group, and combining the target voice fragments into an array according to the sequence of the target character fragments in the broadcast text.
S307, calculating the playing time of each target voice segment, sequentially setting each voice segment as a notified sound (sound effect file), and sequentially playing an array formed by the sound effect files by using a dispatch _ after function.
By adopting the method, a ServiceExtension class is created, and the ServiceExtension class and the target application program are added into an application group (APP group), so that when an application server sends a notification to the target application program in a completely closed state, the ServiceExtension class intercepts the notification by calling a dirreceivenotificationrequest method, acquires a broadcast text of the notification, decomposes the notification into target character fragments and selects corresponding target voice fragments, then combines a plurality of target voice fragments into an array according to the sequence of the target character fragments in the broadcast text, calculates the playing time of each target voice fragment, sequentially sets each voice fragment as a sound (sound effect file) of the notification, and then sequentially plays the array consisting of the sound effect files by using a dispatch _ after function. By the method, the problem that after the IOS12.1, under the condition that the application program is completely closed, voice broadcast notification cannot be carried out is solved.
Fig. 4 is a block diagram illustrating an apparatus 400 for broadcasting a notification by voice according to an exemplary embodiment, the apparatus 400 being applied to a terminal, as shown in fig. 4, and including:
a 401 obtaining module, configured to obtain, for a notification sent by an application server to a target application program in a closed state on the terminal, a broadcast text of the notification;
a 402 decomposition module, configured to decompose the broadcast text into a plurality of target character segments, where one target character segment at least includes one character;
a 403 corresponding module, configured to select, according to a first corresponding relationship between the character segments and the voice segments, a plurality of target voice segments in a preset voice segment library, where the target voice segments correspond to the target character segments one to one;
and the 404 playing module is used for combining the target voice fragments into broadcast audio to play according to the sequence of the target character fragments in the broadcast text.
By adopting the device, the notification sent to the target application program in the closed state on the terminal by the application server is obtained, the broadcast text of the notification is obtained and decomposed into a plurality of target character segments, then a plurality of target voice segments corresponding to the target character segments one by one are selected in a preset voice segment library according to the first corresponding relation between the character segments and the voice segments, and finally the target voice segments are combined into broadcast audio for playing according to the sequence of the target character segments in the broadcast text. The device is used for carrying out voice broadcast notification, and the problem that the voice broadcast notification cannot be carried out under the condition that the application program is completely closed is solved.
Optionally, the obtaining module 401 is configured to:
determining a target notification extended text corresponding to the target notification type parameter according to the target notification type parameter of the notification and a second corresponding relation between the notification type parameter of the target application program and the notification extended text;
and composing the text content of the notification and the target notification extension text into the broadcast text.
Optionally, the preset speech segment library is stored in a storage path of the target application program.
Optionally, the data sharing space APP Groups of the application program of the terminal includes the target application program and a preset ServiceExtension class, the ServiceExtension class includes a didReceiveNotifacationRequest method, and the ServiceExtension class can intercept the notification sent by the application server in the data sharing space by the didReceiveNotifacationRequest method, and execute the method step of acquiring the broadcast text of the notification for the notification until the target voice fragments are combined into a broadcast audio for playing.
Optionally, the playing module 404 is configured to:
setting an initial playing time;
sequencing the target voice fragments according to the sequence of the target character fragments in the broadcast text, and determining the starting playing time of each target voice fragment according to the initial playing time and the sum of the playing durations of all target voice fragments before the target voice fragment in the sequencing;
and combining the target voice segments into broadcast audio to be played according to the initial playing time and the starting playing time of each target voice segment.
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.
The disclosed embodiments also provide a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the steps of the method provided by the above embodiments.
An embodiment of the present disclosure further provides an electronic device, including:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the methods provided by the above embodiments.
Fig. 5 is a block diagram illustrating an electronic device 500 in accordance with an example embodiment. As shown in fig. 5, the electronic device 500 may include: a processor 501 and a memory 502. The electronic device 500 may also include one or more of a multimedia component 503, an input/output (I/O) interface 504, and a communication component 505.
The processor 501 is configured to control the overall operation of the electronic device 500, so as to complete all or part of the steps in the above method for broadcasting the notification by voice. The memory 502 is used to store various types of data to support operation at the electronic device 500, such as instructions for any application or method operating on the electronic device 500 and application-related data, such as contact data, messaging, pictures, audio, video, and so forth. The Memory 502 may be implemented by any type of volatile or non-volatile Memory device or combination thereof, 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 disk or optical disk. The multimedia component 503 may include a screen and an audio component. Wherein the screen may be, for example, a touch screen and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 502 or transmitted through the communication component 505. The audio assembly also includes at least one speaker for outputting audio signals. The I/O interface 504 provides an interface between the processor 501 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 505 is used for wired or wireless communication between the electronic device 500 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, which is not limited herein. The corresponding communication component 505 may thus comprise: Wi-Fi module, Bluetooth module, NFC module, etc.
In an exemplary embodiment, the electronic Device 500 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, microcontrollers, microprocessors, or other electronic components for performing the above-described method of voice announcement.
In another exemplary embodiment, there is also provided a computer readable storage medium including program instructions which, when executed by a processor, implement the steps of the above-described method of voice announcement notification. For example, the computer readable storage medium may be the memory 502 described above that includes program instructions that are executable by the processor 501 of the electronic device 500 to perform the method described above for voice announcement notification.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.