liviosoares / go-watson-sdk Goto Github PK
View Code? Open in Web Editor NEWGo (golang) SDK for IBM Watson services
License: Apache License 2.0
Go (golang) SDK for IBM Watson services
License: Apache License 2.0
Hi, I design a simple dialog that provide me some answers, so , always that I try to get an answer , I get the greetings, then I don't know how to indicate to the c.Message
the current conversation.
When I call Synthesize method to make text to speech,I want to set voice speed,how to do it???
It would be good to add support for the X-Watson-Learning-Opt-Out header to enable users to opt out of Watson tracking their data.
code: 401; message: Unauthorized
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!
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.