Giter Club home page Giter Club logo

go-watson-sdk's People

Contributors

liviosoares avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

go-watson-sdk's Issues

watson/speech_to_text: very slow responses

Hello there @liviosoares, thank you for the great library and for the hardwork!

We are interested in using your packages. However, we aren't able to use it to stream to Watson wav files past the first chunk of data. This is irrespective of if we use streamResults

map[string]interface{}{
     "continuous": true,
     "interim_results": false,
}

"continuous" -> true/false, "interim_results" -> true/false
using the audio in this media https://j.gifs.com/v24y80.mp4, it takes about 1m 40seconds to get back a single response from the websocket for a single chunk of 32768 bytes, and the program stalls for all that time too waiting to even run readReplies. We never get past the first chunk

writing chunk of size: 32768
chunkCount: [c:0] sendTime: 1477351568
time to receive chunk: [c:0] 1m40.098601911s

To rule out problems, it takes about 1 second to make the .wav audio file and here is a sample setup of what am doing:

eventsChan, wc, err := client.NewStream("start", "audio/wav", streamConfig)
...

f, err := os.Open(theWAVPath)
...
go func() {
    defer wc.Close()
    defer f.Close()
     _, _ = io.Copy(wc, f)
}()

combined with the diff below

diff --git a/watson/speech_to_text/speech_to_text.go b/watson/speech_to_text/speech_to_text.go
index 55847b7..a801ba3 100644
--- a/watson/speech_to_text/speech_to_text.go
+++ b/watson/speech_to_text/speech_to_text.go
@@ -19,8 +19,11 @@ package speech_to_text
 import (
    "encoding/json"
    "errors"
+   "fmt"
    "io"
    "net/url"
+   "sync"
+   "time"

    "github.com/liviosoares/go-watson-sdk/watson"
    "github.com/liviosoares/go-watson-sdk/watson/authorization"
@@ -224,10 +227,38 @@ type stream struct {
    stopped        bool
 }

+type counter struct {
+   sync.RWMutex
+   count uint64
+}
+
+func (c *counter) increment() {
+   c.Lock()
+   c.count += 1
+   c.Unlock()
+}
+
+func (c *counter) value() uint64 {
+   c.RLock()
+   defer c.RUnlock()
+
+   return c.count
+}
+
+func (c *counter) String() string {
+   c.RLock()
+   defer c.RUnlock()
+
+   return fmt.Sprintf("[c:%d]", c.count)
+}
+
+var chunkCounter = new(counter)
+
 func (s *stream) Write(p []byte) (n int, err error) {
    if s.stopped {
        return 0, errors.New("cannot write to stopped stream")
    }
+   fmt.Printf("writing chunk of size: %d\n", len(p))
    if !s.started {
        m := make(map[string]interface{})
        for k, v := range s.options {
@@ -242,6 +273,8 @@ func (s *stream) Write(p []byte) (n int, err error) {
            }
        }
        m["interim_results"] = true
+       sendTime := time.Now()
+       fmt.Printf("chunkCount: %s sendTime: %d\n", chunkCounter, sendTime.Unix())
        err := websocket.JSON.Send(s.ws, m)
        if err != nil {
            return 0, err
@@ -249,6 +282,8 @@ func (s *stream) Write(p []byte) (n int, err error) {
        s.started = true
        var state StateReply
        err = websocket.JSON.Receive(s.ws, &state)
+       fmt.Printf("time to receive chunk: %s %s\n", chunkCounter, time.Since(sendTime))
+       chunkCounter.increment()
        if err != nil {
            return 0, err
        }

I tested the code without the counter code before and it was the same thing, stalled response for which it never gets to read the second chunk.

Thank you!

set text_to_speech voice speed

One of the problems I had was how to set the audio speed when using the go-watson-sdk to convert text to speech. The method I'm calling is Synthesize. Is that the method I'm calling wrong? My question is: how do I set the speed of audio

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.