package main

import (
	"fmt"
	"os"
	"time"

	"gitlab.com/cinnamon/voiceagent/stt"
)

func main() {

	//////////// file open start
	file, err := os.Open("./9001-RX-1648533187911907029.pcm")
	if err != nil {
		fmt.Println(err)
	}

	files, serr := file.Stat()
	if serr != nil {
		fmt.Println(serr)
	}

	defer file.Close()
	//////////// file open end

	//////////// stt connect start
	fmt.Println("STT Stat ")
	startTime := time.Now()
	stts, cerr := stt.NewSTTS("220.86.110.194", 9500)
	if cerr != nil {
		fmt.Println("error : ", cerr)
	}

	defer stts.Close()

	data1 := make([]byte, files.Size())
	file.Read(data1)
	result, serr1 := stts.SendSTT(data1)
	if serr != nil {
		fmt.Println(serr1)
	}
	fmt.Printf("stt result [%s]\n", result)
	fmt.Printf("STT END\n Time duration %v\n", time.Since(startTime))
}
