diff --git a/go-api-examples/add-punctuation/go.mod b/go-api-examples/add-punctuation/go.mod index ec6d7580..519523d2 100644 --- a/go-api-examples/add-punctuation/go.mod +++ b/go-api-examples/add-punctuation/go.mod @@ -1,3 +1,3 @@ module add-punctuation -go 1.12 +go 1.17 diff --git a/go-api-examples/audio-tagging/go.mod b/go-api-examples/audio-tagging/go.mod index 63158071..e01ea022 100644 --- a/go-api-examples/audio-tagging/go.mod +++ b/go-api-examples/audio-tagging/go.mod @@ -1,4 +1,4 @@ module audio-tagging -go 1.12 +go 1.17 diff --git a/go-api-examples/keyword-spotting-from-file/go.mod b/go-api-examples/keyword-spotting-from-file/go.mod index dbd349a5..e38195ad 100644 --- a/go-api-examples/keyword-spotting-from-file/go.mod +++ b/go-api-examples/keyword-spotting-from-file/go.mod @@ -1,4 +1,4 @@ module keyword-spotting-from-file -go 1.12 +go 1.17 diff --git a/go-api-examples/non-streaming-decode-files/go.mod b/go-api-examples/non-streaming-decode-files/go.mod index c52a51d4..5e489347 100644 --- a/go-api-examples/non-streaming-decode-files/go.mod +++ b/go-api-examples/non-streaming-decode-files/go.mod @@ -1,3 +1,3 @@ module non-streaming-decode-files -go 1.12 +go 1.17 diff --git a/go-api-examples/non-streaming-speaker-diarization/go.mod b/go-api-examples/non-streaming-speaker-diarization/go.mod index 39edcecf..e64952ea 100644 --- a/go-api-examples/non-streaming-speaker-diarization/go.mod +++ b/go-api-examples/non-streaming-speaker-diarization/go.mod @@ -1,3 +1,3 @@ module non-streaming-speaker-diarization -go 1.12 +go 1.17 diff --git a/go-api-examples/non-streaming-tts/go.mod b/go-api-examples/non-streaming-tts/go.mod index 54127dc8..e9331814 100644 --- a/go-api-examples/non-streaming-tts/go.mod +++ b/go-api-examples/non-streaming-tts/go.mod @@ -1,3 +1,3 @@ module non-streaming-tts -go 1.12 +go 1.17 diff --git a/go-api-examples/real-time-speech-recognition-from-microphone/go.mod b/go-api-examples/real-time-speech-recognition-from-microphone/go.mod index 636d6f79..58f35f46 100644 --- a/go-api-examples/real-time-speech-recognition-from-microphone/go.mod +++ b/go-api-examples/real-time-speech-recognition-from-microphone/go.mod @@ -1,6 +1,6 @@ module real-time-speech-recognition-from-microphone -go 1.12 +go 1.17 require ( github.com/csukuangfj/portaudio-go v1.0.3 diff --git a/go-api-examples/speaker-identification/go.mod b/go-api-examples/speaker-identification/go.mod index 188a7b98..163048ee 100644 --- a/go-api-examples/speaker-identification/go.mod +++ b/go-api-examples/speaker-identification/go.mod @@ -1,3 +1,3 @@ module speaker-identification -go 1.12 +go 1.17 diff --git a/go-api-examples/streaming-decode-files/go.mod b/go-api-examples/streaming-decode-files/go.mod index 8f30fdaf..8fded1b5 100644 --- a/go-api-examples/streaming-decode-files/go.mod +++ b/go-api-examples/streaming-decode-files/go.mod @@ -1,3 +1,3 @@ module streaming-decode-files -go 1.12 +go 1.17 diff --git a/go-api-examples/streaming-hlg-decoding/go.mod b/go-api-examples/streaming-hlg-decoding/go.mod index 1b9b9893..bba387ed 100644 --- a/go-api-examples/streaming-hlg-decoding/go.mod +++ b/go-api-examples/streaming-hlg-decoding/go.mod @@ -1,3 +1,3 @@ module streaming-hlg-decoding -go 1.12 +go 1.17 diff --git a/go-api-examples/vad-asr-paraformer/go.mod b/go-api-examples/vad-asr-paraformer/go.mod index a0b6ae7c..7e6cf7ba 100644 --- a/go-api-examples/vad-asr-paraformer/go.mod +++ b/go-api-examples/vad-asr-paraformer/go.mod @@ -1,3 +1,3 @@ module vad-asr-paraformer -go 1.12 +go 1.17 diff --git a/go-api-examples/vad-asr-whisper/go.mod b/go-api-examples/vad-asr-whisper/go.mod index d19bd106..1fa59b1d 100644 --- a/go-api-examples/vad-asr-whisper/go.mod +++ b/go-api-examples/vad-asr-whisper/go.mod @@ -1,3 +1,3 @@ module vad-asr-whisper -go 1.12 +go 1.17 diff --git a/go-api-examples/vad-speaker-identification/go.mod b/go-api-examples/vad-speaker-identification/go.mod index 9b1f1563..89f73301 100644 --- a/go-api-examples/vad-speaker-identification/go.mod +++ b/go-api-examples/vad-speaker-identification/go.mod @@ -1,3 +1,3 @@ module vad-speaker-identification -go 1.12 +go 1.17 diff --git a/go-api-examples/vad-spoken-language-identification/go.mod b/go-api-examples/vad-spoken-language-identification/go.mod index 9a806cbd..e9e02f19 100644 --- a/go-api-examples/vad-spoken-language-identification/go.mod +++ b/go-api-examples/vad-spoken-language-identification/go.mod @@ -1,3 +1,3 @@ module vad-spoken-language-identification -go 1.12 +go 1.17 diff --git a/go-api-examples/vad/go.mod b/go-api-examples/vad/go.mod index a7cf7d37..2a612e3e 100644 --- a/go-api-examples/vad/go.mod +++ b/go-api-examples/vad/go.mod @@ -1,3 +1,3 @@ module vad -go 1.12 +go 1.17 diff --git a/scripts/go/_internal/add-punctuation/go.mod b/scripts/go/_internal/add-punctuation/go.mod index f25ca0a8..516a28ae 100644 --- a/scripts/go/_internal/add-punctuation/go.mod +++ b/scripts/go/_internal/add-punctuation/go.mod @@ -1,5 +1,5 @@ module add-punctuation -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/audio-tagging/go.mod b/scripts/go/_internal/audio-tagging/go.mod index e19aae58..9e307b29 100644 --- a/scripts/go/_internal/audio-tagging/go.mod +++ b/scripts/go/_internal/audio-tagging/go.mod @@ -1,5 +1,5 @@ module audio-tagging -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/go.mod b/scripts/go/_internal/go.mod index b66f40ec..46e4067e 100644 --- a/scripts/go/_internal/go.mod +++ b/scripts/go/_internal/go.mod @@ -1,3 +1,3 @@ module sherpa_onnx -go 1.12 +go 1.17 diff --git a/scripts/go/_internal/keyword-spotting-from-file/go.mod b/scripts/go/_internal/keyword-spotting-from-file/go.mod index 9cdbc632..b4df0c73 100644 --- a/scripts/go/_internal/keyword-spotting-from-file/go.mod +++ b/scripts/go/_internal/keyword-spotting-from-file/go.mod @@ -1,5 +1,5 @@ module keyword-spotting-from-file -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/non-streaming-decode-files/go.mod b/scripts/go/_internal/non-streaming-decode-files/go.mod index c4f7dc8f..ba08322a 100644 --- a/scripts/go/_internal/non-streaming-decode-files/go.mod +++ b/scripts/go/_internal/non-streaming-decode-files/go.mod @@ -1,5 +1,5 @@ module non-streaming-decode-files -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/non-streaming-speaker-diarization/go.mod b/scripts/go/_internal/non-streaming-speaker-diarization/go.mod index 38ae36d4..dfdb4c1e 100644 --- a/scripts/go/_internal/non-streaming-speaker-diarization/go.mod +++ b/scripts/go/_internal/non-streaming-speaker-diarization/go.mod @@ -1,5 +1,5 @@ module non-streaming-speaker-diarization -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/non-streaming-tts/go.mod b/scripts/go/_internal/non-streaming-tts/go.mod index bbb8b070..5408ae69 100644 --- a/scripts/go/_internal/non-streaming-tts/go.mod +++ b/scripts/go/_internal/non-streaming-tts/go.mod @@ -1,5 +1,5 @@ module non-streaming-tts -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/real-time-speech-recognition-from-microphone/go.mod b/scripts/go/_internal/real-time-speech-recognition-from-microphone/go.mod index e6b64f3c..51093a38 100644 --- a/scripts/go/_internal/real-time-speech-recognition-from-microphone/go.mod +++ b/scripts/go/_internal/real-time-speech-recognition-from-microphone/go.mod @@ -1,5 +1,5 @@ module real-time-speech-recognition-from-microphone -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/speaker-identification/go.mod b/scripts/go/_internal/speaker-identification/go.mod index 38c62bc3..a48cd422 100644 --- a/scripts/go/_internal/speaker-identification/go.mod +++ b/scripts/go/_internal/speaker-identification/go.mod @@ -1,5 +1,5 @@ module speaker-identification -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/streaming-decode-files/go.mod b/scripts/go/_internal/streaming-decode-files/go.mod index 34d87358..623ed0fb 100644 --- a/scripts/go/_internal/streaming-decode-files/go.mod +++ b/scripts/go/_internal/streaming-decode-files/go.mod @@ -1,5 +1,5 @@ module streaming-decode-files -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/streaming-hlg-decoding/go.mod b/scripts/go/_internal/streaming-hlg-decoding/go.mod index 55c0c92a..10840e31 100644 --- a/scripts/go/_internal/streaming-hlg-decoding/go.mod +++ b/scripts/go/_internal/streaming-hlg-decoding/go.mod @@ -1,5 +1,5 @@ module streaming-hlg-decoding -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/vad-asr-paraformer/go.mod b/scripts/go/_internal/vad-asr-paraformer/go.mod index 7b763cc8..629b87c3 100644 --- a/scripts/go/_internal/vad-asr-paraformer/go.mod +++ b/scripts/go/_internal/vad-asr-paraformer/go.mod @@ -1,5 +1,5 @@ module vad-asr-paraformer -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/vad-asr-whisper/go.mod b/scripts/go/_internal/vad-asr-whisper/go.mod index 2de3a523..3cc8b8aa 100644 --- a/scripts/go/_internal/vad-asr-whisper/go.mod +++ b/scripts/go/_internal/vad-asr-whisper/go.mod @@ -1,5 +1,5 @@ module vad-asr-whisper -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/vad-speaker-identification/go.mod b/scripts/go/_internal/vad-speaker-identification/go.mod index faee85d3..7bd688b4 100644 --- a/scripts/go/_internal/vad-speaker-identification/go.mod +++ b/scripts/go/_internal/vad-speaker-identification/go.mod @@ -1,5 +1,5 @@ module vad-speaker-identification -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/vad-spoken-language-identification/go.mod b/scripts/go/_internal/vad-spoken-language-identification/go.mod index 9b66564e..0ddfafd0 100644 --- a/scripts/go/_internal/vad-spoken-language-identification/go.mod +++ b/scripts/go/_internal/vad-spoken-language-identification/go.mod @@ -1,5 +1,5 @@ module vad-spoken-language-identification -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/_internal/vad/go.mod b/scripts/go/_internal/vad/go.mod index e9b4fefc..5179cf2c 100644 --- a/scripts/go/_internal/vad/go.mod +++ b/scripts/go/_internal/vad/go.mod @@ -1,5 +1,5 @@ module vad -go 1.12 +go 1.17 replace github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx => ../ diff --git a/scripts/go/sherpa_onnx.go b/scripts/go/sherpa_onnx.go index 269ea390..202638a7 100644 --- a/scripts/go/sherpa_onnx.go +++ b/scripts/go/sherpa_onnx.go @@ -659,7 +659,7 @@ func (s *OfflineStream) GetResult() *OfflineRecognizerResult { result.Emotion = C.GoString(p.emotion) result.Event = C.GoString(p.event) result.Tokens = make([]string, n) - tokens := (*[1 << 10]*C.char)(unsafe.Pointer(p.tokens_arr))[:n:n] + tokens := unsafe.Slice(p.tokens_arr, n) for i := 0; i < n; i++ { result.Tokens[i] = C.GoString(tokens[i]) } @@ -667,7 +667,7 @@ func (s *OfflineStream) GetResult() *OfflineRecognizerResult { return result } result.Timestamps = make([]float32, n) - timestamps := (*[1 << 10]C.float)(unsafe.Pointer(p.timestamps))[:n:n] + timestamps := unsafe.Slice(p.timestamps, n) for i := 0; i < n; i++ { result.Timestamps[i] = float32(timestamps[i]) } @@ -858,7 +858,7 @@ func (tts *OfflineTts) Generate(text string, sid int, speed float32) *GeneratedA // see https://stackoverflow.com/questions/48756732/what-does-1-30c-yourtype-do-exactly-in-cgo // :n:n means 0:n:n, means low:high:capacity - samples := (*[1 << 10]C.float)(unsafe.Pointer(audio.samples))[:n:n] + samples := unsafe.Slice(audio.samples, n) // copy(ans.Samples, samples) for i := 0; i < n; i++ { ans.Samples[i] = float32(samples[i]) @@ -921,7 +921,7 @@ func (buffer *CircularBuffer) Get(start int, n int) []float32 { result := make([]float32, n) - p := (*[1 << 10]C.float)(unsafe.Pointer(samples))[:n:n] + p := unsafe.Slice(samples, n) for i := 0; i < n; i++ { result[i] = float32(p[i]) } @@ -1017,7 +1017,7 @@ func (vad *VoiceActivityDetector) Front() *SpeechSegment { n := int(f.n) ans.Samples = make([]float32, n) - samples := (*[1 << 10]C.float)(unsafe.Pointer(f.samples))[:n:n] + samples := unsafe.Slice(f.samples, n) for i := 0; i < n; i++ { ans.Samples[i] = float32(samples[i]) @@ -1171,7 +1171,7 @@ func (ex *SpeakerEmbeddingExtractor) Compute(stream *OnlineStream) []float32 { // see https://stackoverflow.com/questions/48756732/what-does-1-30c-yourtype-do-exactly-in-cgo // :n:n means 0:n:n, means low:high:capacity - c := (*[1 << 10]C.float)(unsafe.Pointer(embedding))[:n:n] + c := unsafe.Slice(embedding, n) for i := 0; i < n; i++ { ans[i] = float32(c[i]) @@ -1273,7 +1273,7 @@ func (m *SpeakerEmbeddingManager) AllSpeakers() []string { } // https://stackoverflow.com/questions/62012070/convert-array-of-strings-from-cgo-in-go - p := (*[1 << 10]*C.char)(unsafe.Pointer(all_speakers))[:n:n] + p := unsafe.Slice(all_speakers, n) ans := make([]string, n) @@ -1307,7 +1307,7 @@ func ReadWave(filename string) *Wave { ans := &Wave{} ans.SampleRate = int(w.sample_rate) - samples := (*[1 << 10]C.float)(unsafe.Pointer(w.samples))[:n:n] + samples := unsafe.Slice(w.samples, n) ans.Samples = make([]float32, n) @@ -1428,7 +1428,7 @@ func (sd *OfflineSpeakerDiarization) Process(samples []float32) []OfflineSpeaker ans := make([]OfflineSpeakerDiarizationSegment, n) - p := (*[1 << 10]C.struct_SherpaOnnxOfflineSpeakerDiarizationSegment)(unsafe.Pointer(s))[:n:n] + p := unsafe.Slice(s, n) for i := 0; i < n; i++ { ans[i].Start = float32(p[i].start) @@ -1725,7 +1725,7 @@ func (tagging *AudioTagging) Compute(s *OfflineStream, topK int32) []AudioEvent defer C.SherpaOnnxAudioTaggingFreeResults(r) result := make([]AudioEvent, 0) - p := (*[1 << 10]*C.struct_SherpaOnnxAudioEvent)(unsafe.Pointer(r)) + p := (*[1 << 25]*C.struct_SherpaOnnxAudioEvent)(unsafe.Pointer(r)) i := 0 for { if p[i] == nil {