GithubHelp home page GithubHelp logo

Comments (13)

mamoonraja avatar mamoonraja commented on July 21, 2024

@yuyaito Thanks a lot for opening the issue, we will try to include a patch fix for this one in next release.

from ruby-sdk.

yuyaito avatar yuyaito commented on July 21, 2024

Thank you for your response.

I have additional an information and a question.

Information.
In established one or more connection with Watson STT, if one websocket connection with Watson STT is closed, all the others connection is disconnected at the same time.
I think that a cause of this issue is below code.

     on_close = lambda do |_event|
      @client = nil
      EM.stop_event_loop
    end

The instance of Event Machine is one so all connection is stopped by stop_event_loop.
Please fix it additionally.

Question.
When is next release for fix this issue?

Thank you.

from ruby-sdk.

germanattanasio avatar germanattanasio commented on July 21, 2024

It will probably be fixed the first or second week of January. Right now most of the developers and on vacation.

from ruby-sdk.

mamoonraja avatar mamoonraja commented on July 21, 2024

@yuyaito I was able to re-create the first issue, and we will submit a patch for that. But I cannot re-create the second one you mentioned, can you please provide a snippet of how you are calling the web socket method.

from ruby-sdk.

yuyaito avatar yuyaito commented on July 21, 2024

Thank you for your confirmation.
Steps to reproduce as below.

  1. Modify ruby SDK as below.
    websocket/speech_to_text_websocket_listener.rb l78
#before
EM&.reactor_thread&.join
#after
#EM&.reactor_thread&.join
  1. Open two or more websocket connection with watson STT using modified SDK.

  2. Close one of websocket connection. all the others connection is closed at the same time.

on_close = lambda do |_event|
  @client = nil
  EM.stop_event_loop
end

from ruby-sdk.

yuyaito avatar yuyaito commented on July 21, 2024

Please answer the question about this issue.

Q1. Please tell me the progress for this issue.

Q2. Could you understand the reason of problem?

Q3. When is the release for fix this issue?

from ruby-sdk.

mamoonraja avatar mamoonraja commented on July 21, 2024

Hi @yuyaito, We are investigating issues related to STT WebSocket and we are planning to have a patch out by the end of this month, and we are tracking work here.

from ruby-sdk.

germanattanasio avatar germanattanasio commented on July 21, 2024

@mamoonraja will this be fixed with the new release?

from ruby-sdk.

mamoonraja avatar mamoonraja commented on July 21, 2024

I am investigating this one.

from ruby-sdk.

mamoonraja avatar mamoonraja commented on July 21, 2024

@yuyaito I have verified that functionality to do recognition using 2 or more connections is working, we added an example of how to use WebSockets in multiple threads here. E.g, To create two threads, you need to create two wrappers of service and then start the event machine in separate threads. Here's an example snippet:

speech = speech_to_text.recognize_using_websocket(
  audio: File.open(Dir.getwd + "/resources/speech.wav"),
  recognize_callback: MyRecognizeCallback.new,
  interim_results: true,
  timestamps: true,
  max_alternatives: 2,
  word_alternatives_threshold: 0.5,
  content_type: "audio/wav"
)

speech_with_pause = speech_to_text.recognize_using_websocket(
  audio: File.open(Dir.getwd + "/resources/sound-with-pause.wav"),
  recognize_callback: MyRecognizeCallback.new,
  interim_results: true,
  timestamps: true,
  max_alternatives: 2,
  word_alternatives_threshold: 0.5,
  content_type: "audio/wav"
)

main_thread = Thread.new { speech.start }
another_thread = Thread.new { speech_with_pause.start }

main_thread.join
another_thread.join

Please feel free to re-open if the issue persists.

from ruby-sdk.

alpha-netzilla avatar alpha-netzilla commented on July 21, 2024

Could you re-open this issue? I faced the same problem mentioned here.

WebSocket in STT on this SDK does not run correctly when calling two or more "recognize_using_websocket" method in Ruby on Rails(RoR).

The program stops at the following code.

# STOP ("ibm_watson/websocket/speech_to_text_websocket_listener.rb")
EM&.reactor_thread&.join

I came to mind as to what caused this problem.

This SDK uses EventMachine(EM).

The EM manual says that
it will result in Web server never binding to the socket). In that case, start event loop in a separate thread as demonstrated below.
https://www.rubydoc.info/github/eventmachine/eventmachine/EventMachine.run

I tried starting EventMachine event loop in a separate thread. The SDK no longer blocks the program.

Thread.new { EM.run -snip-} # at ibm_watson/websocket/speech_to_text_websocket_listener.rb"

If you have any concerns, please share them with us.

Would it be possible for you to do some action to avoid confusion when using this SDK with WEB app.

from ruby-sdk.

mamoonraja avatar mamoonraja commented on July 21, 2024

Hi! Looks like your problem was solved using the example for Starting EventMachine event loop in a separate thread in https://www.rubydoc.info/github/eventmachine/eventmachine/EventMachine.run.

We do provide an example here: https://github.com/watson-developer-cloud/ruby-sdk/blob/master/examples/speech_to_text_v1.rb#L102 that shows how to run the program in a separate thread, which is similar to the example you posted.

Do you still need the issue to be opened again because it sounds like it's working for you now?

from ruby-sdk.

alpha-netzilla avatar alpha-netzilla commented on July 21, 2024

I solved the problem and the behavior is a specification of EM rather than a bug.
Furthermore, these comments are useful for developers who get lost in how to use.

I do not need the issue to be opened. Thanks for your comment.

from ruby-sdk.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.