This message was deleted.
# helpdesk
s
This message was deleted.
m
@best-france-45538 no plans for that currently. We stream speech as an audio track in WebRTC. WebSocket uses TCP which isn’t designed for streaming media. Is there a particular reason your interested in that route? What are you trying to build?
We would like to add/support STT/TTS from other providers though, if that’s what you mean. If you end up building support for that, we accept PRs! 😊
👍 1
b
Sure thing! I'm trying to integrate STT/TTS from providers in China, eg. Baidu & Ali,
👍 1
Hi Bro! I have an question about KITT.Currently, I’m trying to read out the speech stream as you did in
lkgpt-service/pkg/service/transcriber.go
, since the ASR API I tried to use just received PCM raw data, so I tried to modify the code in
start()
to use https://github.com/hraban/opus to decode ogg data to pcm data as following
Copy code
stream, err:= opus.NewStream(t.oggReader)
                        if err != nil {
                                logger.Errorw("failed to create opus decoder", err)
                        }
but got
failed to create opus decoder	{"error": "OP_EBADTIMESTAMP"}
error. I’m new to golang, so have no idea if I use a wrong lib? or any other ways to get pcm raw data ? THANK YOU VERY MUCH!
m
Any thoughts on decoding the audio in Go @boundless-energy-78552 @dry-elephant-14928 ?
d
I'm not familiar with the library you are using, but it's worth trying manually passing through each sample as noted in this section. The
NewStream
API might be expecting certain Opus/Ogg headers that aren't present in the stream.
b
Thank you! Actually, I tried the the way to decode it by each chunk which read out by oggReader, but no lucky either. 😅
Hi Team, I added a function by using “mccoy.space/g/ogg
Copy code
import (	
   "<http://mccoy.space/g/ogg|mccoy.space/g/ogg>"
)

func OggToPCM(data []byte) ([]byte) {
        decoder := ogg.NewDecoder(bytes.NewReader(data))
        page, err := decoder.Decode()
        if err != nil {
                logger.Errorw("Error while decoding opus file: %v", err)
                return nil
        }
        //fmt.Println("ogg data has %d pages", len(page.Packets))
        audiodata := make([]byte, 0)
        for i:=0; i< len(page.Packets); i++ {
                audiodata = append(audiodata, page.Packets[i]...)
        }
        return audiodata
}
and update
transcriber.go
as following
Copy code
go func() {
                        defer close(nextCh)
                        buf := make([]byte, 1024)
                        for {
                                select {
                                case <-endStreamCh:
                                        return
                                default:
                                        n, err := t.oggReader.Read(buf)
                                        if err != nil {
                                                if err != io.EOF {
                                                        logger.Errorw("failed to read from ogg reader", err)
                                                }
                                                return
                                        }

                                        if n <= 0 {
                                                fmt.Printf("No Data read from OggReader \n")
                                                continue // No data
                                        }

                                        opusdata := OggToPCM(buf[:n])
                                        if opusdata != nil {
                                                opusbytes = append(opusbytes, opusdata...)
                                        } else {
                                                fmt.Printf("No Data from OpusDecode \n")
                                        }
                                }
                        }
                }()
but seems it’s not working neither, any ideas on handle the buffer from
oggReader
and convert it to PCM raw data?