kandi background
Explore Kits

Utterance | Utterance lets you use the platform 's native Text | Speech library

 by   benbahrenburg Java Version: Current License: No License

 by   benbahrenburg Java Version: Current License: No License

kandi X-RAY | Utterance Summary

Utterance is a Java library typically used in Artificial Intelligence, Speech applications. Utterance has no bugs, it has no vulnerabilities and it has low support. However Utterance build file is not available. You can download it from GitHub.
Utterance lets you use your device's native Text to Speech and Speech to Text capabilities in your Titanium projects.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • Utterance has a low active ecosystem.
  • It has 71 star(s) with 30 fork(s). There are 11 watchers for this library.
  • It had no major release in the last 6 months.
  • Utterance has no issues reported. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of Utterance is current.
Utterance Support
Best in #Speech
Average in #Speech
Utterance Support
Best in #Speech
Average in #Speech

quality kandi Quality

  • Utterance has 0 bugs and 0 code smells.
Utterance Quality
Best in #Speech
Average in #Speech
Utterance Quality
Best in #Speech
Average in #Speech

securitySecurity

  • Utterance has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • Utterance code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
Utterance Security
Best in #Speech
Average in #Speech
Utterance Security
Best in #Speech
Average in #Speech

license License

  • Utterance does not have a standard license declared.
  • Check the repository for any license declaration and review the terms closely.
  • Without a license, all rights are reserved, and you cannot use the library in your applications.
Utterance License
Best in #Speech
Average in #Speech
Utterance License
Best in #Speech
Average in #Speech

buildReuse

  • Utterance releases are not available. You will need to build from source code and install.
  • Utterance has no build file. You will be need to create the build yourself to build the component from source.
  • Installation instructions, examples and code snippets are available.
  • Utterance saves you 295 person hours of effort in developing the same functionality from scratch.
  • It has 712 lines of code, 62 functions and 20 files.
  • It has high code complexity. Code complexity directly impacts maintainability of the code.
Utterance Reuse
Best in #Speech
Average in #Speech
Utterance Reuse
Best in #Speech
Average in #Speech
Top functions reviewed by kandi - BETA

kandi has reviewed Utterance and discovered the below as its top functions. This is intended to give you an instant insight into Utterance implemented functionality, and help decide if they suit your requirements.

  • Start speech .
    • Start speech recognition intent .
      • Callback method .
        • Initializes the instance of the TTS .
          • Converts a string to a locale .
            • Called when an error is detected .
              • This method is used to fire event listeners
                • Install TTS data .
                  • Check TTS data installed .
                    • On app create .

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      Utterance Key Features

                      Utterance lets you use the platform's native Text To Speech Engine within your Titanium Project

                      Utterance Examples and Code Snippets

                      See all related Code Snippets

                      Community Discussions

                      Trending Discussions on Utterance
                      • How to update view from callback inside of custom delegate class?
                      • Insert a few columns and rows from one dataframe into another dataframe with many more columns and rows
                      • Detecting missing single parentheses in the presence of potentially missing double parentheses
                      • R Function for Return New Column to Dataset
                      • Summarize grouped character data with true NA in dplyr
                      • Conditionally count and discount members of multiple groups
                      • Count number of utterances by same speakers but discount number of in-between pauses
                      • How to split data into train and test while stratifying on labels and preventing the same entity from appearing both?
                      • Filter dataframe on sequence of rows conditional on two columns
                      • Find last-gazed-at person in Q-A sequences
                      Trending Discussions on Utterance

                      QUESTION

                      How to update view from callback inside of custom delegate class?

                      Asked 2022-Apr-03 at 12:15

                      I am working on a Christian app, all is going well, except for 1 thing: I can't solve how to get the label to update its text after my AVSpeechSynthesizer has finished speaking.

                      For example, after the prayer has finished being read, the text should update to "Play" again. It does this correctly in all other known scenarios (Pause works, Resume works, stop works, restart works, etc. as in the label updates accordingly).

                      Please see my code here:

                      import SwiftUI
                      import AVFoundation
                      
                      class GlobalVarsModel: ObservableObject {
                          @Published var prayerAudioID: UUID?
                          @Published var uttPrayerAudio = ""
                          @Published var strAudioBtnImgStr = "play.fill"
                          @Published var strAudioBtnText = "Play Audio"
                          static let audioSession = AVAudioSession.sharedInstance()
                          static var synthesizer = CustomAVSpeechSynth()
                      }
                      
                      class CustomAVSpeechSynth: AVSpeechSynthesizer, AVSpeechSynthesizerDelegate {
                          
                          //NOT DESIRED OUTPUT LIST
                          //@Published
                          //@ObservedObject
                          //@State
                          
                          @StateObject var gVars = GlobalVarsModel()
                          
                          override init() {
                              super.init()
                              delegate = self
                          }
                          
                          func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didPause utterance: AVSpeechUtterance) {
                          }
                          
                          func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didStart utterance: AVSpeechUtterance) {
                          }
                          
                          func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didCancel utterance: AVSpeechUtterance) {
                          }
                          
                          func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didFinish utterance: AVSpeechUtterance) {
                              print("Finished praying.")
                              print(gVars.strAudioBtnText)
                          }
                          
                          func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didContinue utterance: AVSpeechUtterance) {
                          }
                          
                          func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, willSpeakRangeOfSpeechString characterRange: NSRange, utterance: AVSpeechUtterance) {
                          }
                      }
                      
                      struct TappedPrayerView: View {
                          public var tappedPrayer: Prayer
                          @StateObject public var gVars = GlobalVarsModel()
                          @Environment(\.scenePhase) var scenePhase
                          
                          var body: some View {
                              ScrollView {
                                  VStack {
                                      Text(tappedPrayer.strTitle).font(.title2).padding()
                                      HStack {
                                          Spacer()
                                          Button {
                                              gVars.prayerAudioID = tappedPrayer.id
                                              gVars.uttPrayerAudio = tappedPrayer.strText
                                              
                                              if (gVars.strAudioBtnText == "Play Audio") {
                                                  gVars.strAudioBtnImgStr = "pause.fill"
                                                  gVars.strAudioBtnText = "Pause Audio"
                                                  if (GlobalVarsModel.synthesizer.isSpeaking || GlobalVarsModel.synthesizer.isPaused) {
                                                      GlobalVarsModel.synthesizer.stopSpeaking(at: .immediate)
                                                      GlobalVarsModel.synthesizer.speak(AVSpeechUtterance(string: gVars.uttPrayerAudio))
                                                  } else {
                                                      GlobalVarsModel.synthesizer.speak(AVSpeechUtterance(string: gVars.uttPrayerAudio))
                                                  }
                                              } else if (gVars.strAudioBtnText == "Pause Audio") {
                                                  GlobalVarsModel.synthesizer.pauseSpeaking(at: .immediate)
                                                  gVars.strAudioBtnImgStr = "play.fill"
                                                  gVars.strAudioBtnText = "Continue Audio"
                                              } else if (gVars.strAudioBtnText == "Continue Audio") {
                                                  if (GlobalVarsModel.synthesizer.isPaused) {
                                                      GlobalVarsModel.synthesizer.continueSpeaking()
                                                      gVars.strAudioBtnImgStr = "pause.fill"
                                                      gVars.strAudioBtnText = "Pause Audio"
                                                  }
                                              }
                                          } label: {
                                              Label(gVars.strAudioBtnText, systemImage: gVars.strAudioBtnImgStr).font(.title3).padding()
                                          }.onAppear {
                                              if ((GlobalVarsModel.synthesizer.isSpeaking || GlobalVarsModel.synthesizer.isPaused) && tappedPrayer.id != gVars.prayerAudioID) {
                                                  gVars.strAudioBtnImgStr = "play.fill"
                                                  gVars.strAudioBtnText = "Play Audio"
                                              }
                                          }
                                          Spacer()
                                          Button {
                                              if (GlobalVarsModel.synthesizer.isSpeaking || GlobalVarsModel.synthesizer.isPaused) {
                                                  GlobalVarsModel.synthesizer.stopSpeaking(at: .immediate)
                                                  gVars.strAudioBtnImgStr = "play.fill"
                                                  gVars.strAudioBtnText = "Play Audio"
                                                  gVars.prayerAudioID = UUID(uuidString: String(Int.random(in: 0..<7)) + (gVars.prayerAudioID?.uuidString ?? "777"))
                                              }
                                          } label: {
                                              Label("Restart", systemImage: "restart.circle.fill").font(.title3).padding()
                                          }
                                          Spacer()
                                      }
                                      Spacer()
                                      Text(tappedPrayer.strText).padding()
                                      Spacer()
                                  }
                              }.onAppear {
                                  if (GlobalVarsModel.synthesizer.isPaused) {
                                      if (tappedPrayer.id == gVars.prayerAudioID) {
                                          gVars.strAudioBtnImgStr = "play.fill"
                                          gVars.strAudioBtnText = "Continue Audio"
                                      }
                                  } else if (GlobalVarsModel.synthesizer.isSpeaking) {
                                      if (tappedPrayer.id == gVars.prayerAudioID) {
                                          gVars.strAudioBtnImgStr = "pause.fill"
                                          gVars.strAudioBtnText = "Pause Audio"
                                      }
                                  } else {
                                      gVars.strAudioBtnImgStr = "play.fill"
                                      gVars.strAudioBtnText = "Play Audio"
                                  }
                              }.onChange(of: scenePhase) { newPhase in
                                  if (newPhase == .active) {
                                  } else if (newPhase == .inactive) {
                                  } else if (newPhase == .background) {
                                  }
                              }
                          }
                          
                          struct TappedPrayerView_Previews: PreviewProvider {
                              static var previews: some View {
                                  let defaultPrayer = Prayer(strTitle: "Default title", strText: "Default text")
                                  TappedPrayerView(tappedPrayer: defaultPrayer)
                              }
                          }
                      }
                      

                      ANSWER

                      Answered 2022-Apr-03 at 12:15

                      Multiple issues with your code.

                      1. You are initializing GlobalVarsModel twice. Once in the View and once in the delegate. So changes in one won´t reflect in the other.

                      2. You are implementing the delegate in a subclass of your AVSpeechSynthesizer therefor it is capsulated in it and you can´t update your View when an event arises.

                      I changed the implementation to address this issues:


                      class GlobalVarsViewmodel: NSObject, ObservableObject { //You need to derive from NSObject first, because `AVSpeechSynthesizer` is `objc` related
                          @Published var prayerAudioID: UUID?
                          @Published var uttPrayerAudio = ""
                          @Published var strAudioBtnImgStr = "play.fill"
                          @Published var strAudioBtnText = "Play Audio"
                          let audioSession = AVAudioSession.sharedInstance()
                          var synthesizer = CustomAVSpeechSynth()
                          
                          override init(){
                              super.init()
                              synthesizer.delegate = self // assign the delegate
                          }
                      }
                      
                      extension GlobalVarsViewmodel: AVSpeechSynthesizerDelegate{ // extend the viewmodel to implement the delegate
                          
                          func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didPause utterance: AVSpeechUtterance) {
                          }
                          
                          func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didStart utterance: AVSpeechUtterance) {
                          }
                          
                          func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didCancel utterance: AVSpeechUtterance) {
                          }
                          
                          func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didFinish utterance: AVSpeechUtterance) {
                              print("Finished praying.")
                              strAudioBtnImgStr = "play.fill" // here assign the text and button appearance
                              strAudioBtnText = "Play Audio"
                          }
                          
                          func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didContinue utterance: AVSpeechUtterance) {
                          }
                          
                          func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, willSpeakRangeOfSpeechString characterRange: NSRange, utterance: AVSpeechUtterance) {
                          }
                      }
                      // I don´t think you need this anymore
                      class CustomAVSpeechSynth: AVSpeechSynthesizer {
                          
                          //NOT DESIRED OUTPUT LIST
                          //@Published
                          //@ObservedObject
                          //@State
                      }
                      
                      struct TappedPrayerView: View {
                          var tappedPrayer: Prayer
                          @StateObject private var gVars = GlobalVarsViewmodel()
                          @Environment(\.scenePhase) var scenePhase
                          
                          var body: some View {
                              ScrollView {
                                  VStack {
                                      Text(tappedPrayer.strTitle).font(.title2).padding()
                                      HStack {
                                          Spacer()
                                          Button {
                                              gVars.prayerAudioID = tappedPrayer.id
                                              gVars.uttPrayerAudio = tappedPrayer.strText
                                              
                                              if (gVars.strAudioBtnText == "Play Audio") {
                                                  gVars.strAudioBtnImgStr = "pause.fill"
                                                  gVars.strAudioBtnText = "Pause Audio"
                                                  if (gVars.synthesizer.isSpeaking || gVars.synthesizer.isPaused) {
                                                      gVars.synthesizer.stopSpeaking(at: .immediate)
                                                      gVars.synthesizer.speak(AVSpeechUtterance(string: gVars.uttPrayerAudio))
                                                  } else {
                                                      gVars.synthesizer.speak(AVSpeechUtterance(string: gVars.uttPrayerAudio))
                                                  }
                                              } else if (gVars.strAudioBtnText == "Pause Audio") {
                                                  gVars.synthesizer.pauseSpeaking(at: .immediate)
                                                  gVars.strAudioBtnImgStr = "play.fill"
                                                  gVars.strAudioBtnText = "Continue Audio"
                                              } else if (gVars.strAudioBtnText == "Continue Audio") {
                                                  if (gVars.synthesizer.isPaused) {
                                                      gVars.synthesizer.continueSpeaking()
                                                      gVars.strAudioBtnImgStr = "pause.fill"
                                                      gVars.strAudioBtnText = "Pause Audio"
                                                  }
                                              }
                                          } label: {
                                              Label(gVars.strAudioBtnText, systemImage: gVars.strAudioBtnImgStr).font(.title3).padding()
                                          }.onAppear {
                                              if ((gVars.synthesizer.isSpeaking || gVars.synthesizer.isPaused) && tappedPrayer.id != gVars.prayerAudioID) {
                                                  gVars.strAudioBtnImgStr = "play.fill"
                                                  gVars.strAudioBtnText = "Play Audio"
                                              }
                                          }
                                          Spacer()
                                          Button {
                                              if (gVars.synthesizer.isSpeaking || gVars.synthesizer.isPaused) {
                                                  gVars.synthesizer.stopSpeaking(at: .immediate)
                                                  gVars.strAudioBtnImgStr = "play.fill"
                                                  gVars.strAudioBtnText = "Play Audio"
                                                  gVars.prayerAudioID = UUID(uuidString: String(Int.random(in: 0..<7)) + (gVars.prayerAudioID?.uuidString ?? "777"))
                                              }
                                          } label: {
                                              Label("Restart", systemImage: "restart.circle.fill").font(.title3).padding()
                                          }
                                          Spacer()
                                      }
                                      Spacer()
                                      Text(tappedPrayer.strText).padding()
                                      Spacer()
                                  }
                              }.onAppear {
                                  if (gVars.synthesizer.isPaused) {
                                      if (tappedPrayer.id == gVars.prayerAudioID) {
                                          gVars.strAudioBtnImgStr = "play.fill"
                                          gVars.strAudioBtnText = "Continue Audio"
                                      }
                                  } else if (gVars.synthesizer.isSpeaking) {
                                      if (tappedPrayer.id == gVars.prayerAudioID) {
                                          gVars.strAudioBtnImgStr = "pause.fill"
                                          gVars.strAudioBtnText = "Pause Audio"
                                      }
                                  } else {
                                      gVars.strAudioBtnImgStr = "play.fill"
                                      gVars.strAudioBtnText = "Play Audio"
                                  }
                              }.onChange(of: scenePhase) { newPhase in
                                  if (newPhase == .active) {
                                  } else if (newPhase == .inactive) {
                                  } else if (newPhase == .background) {
                                  }
                              }
                          }
                          
                          struct TappedPrayerView_Previews: PreviewProvider {
                              static var previews: some View {
                                  let defaultPrayer = Prayer(strTitle: "Default title", strText: "Default text")
                                  TappedPrayerView(tappedPrayer: defaultPrayer)
                              }
                          }
                      }
                      

                      Remarks:

                      • I changed the name of GlobalVarsModel to GlobalVarsViewmodel because it is exactly that, a Viewmodel.
                      • I changed the synthesizer var to be instance related instead of static
                      • same for the AVAudioSession

                      Edit to adress the comment for clarification: I changed the implementation from static because it is not needed here. You can read more about it here -> https://www.donnywals.com/effectively-using-static-and-class-methods-and-properties/

                      Source https://stackoverflow.com/questions/71715901

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                      Vulnerabilities

                      No vulnerabilities reported

                      Install Utterance

                      Download the platform you wish to use:.
                      iOS Dist
                      Android Dist
                      Install from gitTio
                      Download the latest release from the releases folder ( or you can build it yourself )
                      Install the Utterance module. If you need help here is a "How To" guide.
                      You can now use the module via the commonJS require method, example shown below.

                      Support

                      For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

                      Find more information at:

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 650 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Clone
                      • https://github.com/benbahrenburg/Utterance.git

                      • gh repo clone benbahrenburg/Utterance

                      • git@github.com:benbahrenburg/Utterance.git

                      Share this Page

                      share link

                      See Similar Libraries in

                      Consider Popular Speech Libraries
                      Try Top Libraries by benbahrenburg
                      Compare Speech Libraries with Highest Support
                      Compare Speech Libraries with Highest Quality
                      Compare Speech Libraries with Highest Security
                      Compare Speech Libraries with Permissive License
                      Compare Speech Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 650 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit