Fix logs and recognition format

This commit is contained in:
2025-08-12 13:57:41 +03:00
parent 6783b7621e
commit a856900504
4 changed files with 41 additions and 10 deletions

View File

@@ -3,7 +3,6 @@ package speechkit
import (
"context"
"fmt"
"log"
"os"
"strings"
@@ -150,10 +149,12 @@ func (s *SpeechKitService) GetRecognitionText(operationID string) (string, error
}
return "", fmt.Errorf("failed to receive recognition response: %w", err)
}
if final := resp.GetFinal(); final != nil {
for _, alt := range final.Alternatives {
sb.WriteString(alt.Text)
sb.WriteString(" ")
if refinement := resp.GetFinalRefinement(); refinement != nil {
if text := refinement.GetNormalizedText(); text != nil {
for _, alt := range text.Alternatives {
sb.WriteString(alt.Text)
sb.WriteString(" ")
}
}
}
}
@@ -168,8 +169,6 @@ func (s *SpeechKitService) CheckOperationStatus(operationID string) (*operation.
ctx = metadata.AppendToOutgoingContext(ctx, "authorization", "Api-Key "+s.apiKey)
ctx = metadata.AppendToOutgoingContext(ctx, "x-folder-id", s.folderID)
log.Printf("Check operation status: id %s\n", operationID)
op, err := s.opClient.Get(ctx, &operation.GetOperationRequest{
OperationId: operationID,
})