Documentation ¶
Overview ¶
Package oggwriter implements OGG media container writer
Index ¶
- Constants
- Variables
- func GetLanguageCode(serviceType, lang string, f func(string) (string, error)) (string, error)
- func GranulePosition(config byte) uint64
- func InitLogger(config *Config) error
- func NewAmazonTranscribeClient(config Config) *transcribestreamingservice.TranscribeStreamingService
- func NewAmazonTranscribeHandler(config Config, channelID, connectionID string, sampleRate uint32, ...) serviceHandlerInterface
- func NewOpusReader(c Config, d time.Duration, opusReader io.ReadCloser) io.ReadCloser
- func NewPacketDumpHandler(config Config, channelID, connectionID string, sampleRate uint32, ...) serviceHandlerInterface
- func NewSpeechToTextHandler(config Config, channelID, connectionID string, sampleRate uint32, ...) serviceHandlerInterface
- func NewSpeechpbRecognitionConfig(rc RecognitionConfig) *speechpb.RecognitionConfig
- func NewStartStreamTranscriptionInput(at *AmazonTranscribe) transcribestreamingservice.StartStreamTranscriptionInput
- func NewStreamingRecognitionConfig(recognitionConfig *speechpb.RecognitionConfig, ...) *speechpb.StreamingRecognizeRequest_StreamingConfig
- func NewTestHandler(config Config, channelID, connectionID string, sampleRate uint32, ...) serviceHandlerInterface
- func ShowConfig(config *Config)
- type AmazonTranscribe
- type AmazonTranscribeHandler
- type AwsResult
- type Config
- type GcpResult
- type OggWriter
- type PacketDumpHandler
- type PacketDumpResult
- type RecognitionConfig
- type Server
- type SpeechToText
- type SpeechToTextHandler
- type SuzuError
- type TestHandler
- type TestResult
- type TranscriptionResult
Constants ¶
View Source
const ( DefaultLogDir = "." DefaultLogName = "suzu.jsonl" // megabytes DefaultLogRotateMaxSize = 200 DefaultLogRotateMaxBackups = 7 // days DefaultLogRotateMaxAge = 30 DefaultExporterListenAddr = "0.0.0.0" DefaultExporterListenPort = 5891 // 10s DefaultTimeToWaitForOpusPacketMs = 10000 // リトライ間隔 100ms DefaultRetryIntervalMs = 100 )
View Source
const ( FrameSize = 1024 * 10 HeaderLength = 20 MaxPayloadLength = 0xffff )
Variables ¶
View Source
var ( ErrMissingAudioStreamingLanguageCode = fmt.Errorf("MISSING-SORA-AUDIO-STREAMING-LANGUAGE-CODE") ErrUnsupportedLanguageCode = fmt.Errorf("UNSUPPORTED-LANGUAGE-CODE") ErrUnsupportedService = fmt.Errorf("UNSUPPORTED-SERVICE") )
View Source
var ( NewServiceHandlerFuncs = make(newServiceHandlerFuncs) ErrServiceNotFound = fmt.Errorf("SERVICE-NOT-FOUND") )
View Source
var ( // TODO: 分かりにくい場合はエラー名を変更する // このエラーの場合は再接続を試みる ErrServerDisconnected = fmt.Errorf("SERVER-DISCONNECTED") )
View Source
var Version string
Functions ¶
func GetLanguageCode ¶
func GranulePosition ¶
func NewAmazonTranscribeClient ¶
func NewAmazonTranscribeClient(config Config) *transcribestreamingservice.TranscribeStreamingService
func NewOpusReader ¶
func NewOpusReader(c Config, d time.Duration, opusReader io.ReadCloser) io.ReadCloser
func NewPacketDumpHandler ¶
func NewSpeechToTextHandler ¶
func NewSpeechpbRecognitionConfig ¶
func NewSpeechpbRecognitionConfig(rc RecognitionConfig) *speechpb.RecognitionConfig
func NewStartStreamTranscriptionInput ¶
func NewStartStreamTranscriptionInput(at *AmazonTranscribe) transcribestreamingservice.StartStreamTranscriptionInput
func NewStreamingRecognitionConfig ¶
func NewStreamingRecognitionConfig(recognitionConfig *speechpb.RecognitionConfig, singleUtterance, interimResults bool) *speechpb.StreamingRecognizeRequest_StreamingConfig
func NewTestHandler ¶
func ShowConfig ¶
func ShowConfig(config *Config)
Types ¶
type AmazonTranscribe ¶
type AmazonTranscribe struct { LanguageCode string MediaEncoding string MediaSampleRateHertz int64 EnablePartialResultsStabilization bool NumberOfChannels int64 EnableChannelIdentification bool PartialResultsStability string Region string Debug bool Config Config }
func NewAmazonTranscribe ¶
func NewAmazonTranscribe(config Config, languageCode string, sampleRateHertz, audioChannelCount int64) *AmazonTranscribe
func (*AmazonTranscribe) Start ¶
func (at *AmazonTranscribe) Start(ctx context.Context, r io.Reader) (*transcribestreamingservice.StartStreamTranscriptionEventStream, error)
type AmazonTranscribeHandler ¶
type AmazonTranscribeHandler struct { Config Config ChannelID string ConnectionID string SampleRate uint32 ChannelCount uint16 LanguageCode string RetryCount int OnResultFunc func(context.Context, io.WriteCloser, string, string, string, any) error // contains filtered or unexported fields }
func (*AmazonTranscribeHandler) GetRetryCount ¶
func (h *AmazonTranscribeHandler) GetRetryCount() int
func (*AmazonTranscribeHandler) Handle ¶
func (h *AmazonTranscribeHandler) Handle(ctx context.Context, reader io.Reader) (*io.PipeReader, error)
func (*AmazonTranscribeHandler) ResetRetryCount ¶
func (h *AmazonTranscribeHandler) ResetRetryCount() int
func (*AmazonTranscribeHandler) UpdateRetryCount ¶
func (h *AmazonTranscribeHandler) UpdateRetryCount() int
type AwsResult ¶
type AwsResult struct { ChannelID *string `json:"channel_id,omitempty"` IsPartial *bool `json:"is_partial,omitempty"` ResultID *string `json:"result_id,omitempty"` TranscriptionResult }
func NewAwsResult ¶
func NewAwsResult() AwsResult
func (*AwsResult) SetMessage ¶
func (*AwsResult) WithChannelID ¶
func (*AwsResult) WithIsPartial ¶
func (*AwsResult) WithResultID ¶
type Config ¶
type Config struct { Version string Debug bool `ini:"debug"` HTTPS bool `ini:"https"` ListenAddr string `ini:"listen_addr"` ListenPort int `ini:"listen_port"` AudioStreamingHeader bool `ini:"audio_streaming_header"` TLSFullchainFile string `ini:"tls_fullchain_file"` TLSPrivkeyFile string `ini:"tls_privkey_file"` TLSVerifyCacertPath string `ini:"tls_verify_cacert_path"` // クライアント認証用 HTTP2MaxConcurrentStreams uint32 `ini:"http2_max_concurrent_streams"` HTTP2MaxReadFrameSize uint32 `ini:"http2_max_read_frame_size"` HTTP2IdleTimeout uint32 `ini:"http2_idle_timeout"` MaxRetry int `ini:"max_retry"` RetryIntervalMs int `ini:"retry_interval_ms"` ExporterHTTPS bool `ini:"exporter_https"` ExporterListenAddr string `ini:"exporter_listen_addr"` ExporterListenPort int `ini:"exporter_listen_port"` SkipBasicAuth bool `ini:"skip_basic_auth"` BasicAuthUsername string `ini:"basic_auth_username"` BasicAuthPassword string `ini:"basic_auth_password"` SampleRate int `ini:"audio_sample_rate"` ChannelCount int `ini:"audio_channel_count"` DumpFile string `ini:"dump_file"` LogDir string `ini:"log_dir"` LogName string `ini:"log_name"` LogStdout bool `ini:"log_stdout"` LogRotateMaxSize int `ini:"log_rotate_max_size"` LogRotateMaxBackups int `ini:"log_rotate_max_backups"` LogRotateMaxAge int `ini:"log_rotate_max_age"` TimeToWaitForOpusPacketMs int `ini:"time_to_wait_for_opus_packet_ms"` // aws の場合は IsPartial が false, gcp の場合は IsFinal が true の場合にのみ結果を返す指定 FinalResultOnly bool `ini:"final_result_only"` // Amazon Web Services AwsCredentialFile string `ini:"aws_credential_file"` AwsProfile string `ini:"aws_profile"` AwsRegion string `ini:"aws_region"` AwsEnablePartialResultsStabilization bool `ini:"aws_enable_partial_results_stabilization"` AwsPartialResultsStability string `ini:"aws_partial_results_stability"` AwsEnableChannelIdentification bool `ini:"aws_enable_channel_identification"` // 変換結果に含める項目の有無の指定 AwsResultChannelID bool `ini:"aws_result_channel_id"` AwsResultIsPartial bool `ini:"aws_result_is_partial"` AwsResultID bool `ini:"aws_result_id"` // Google Cloud Platform GcpCredentialFile string `ini:"gcp_credential_file"` GcpEnableSeparateRecognitionPerChannel bool `ini:"gcp_enable_separate_recognition_per_channel"` GcpAlternativeLanguageCodes []string `ini:"gcp_alternative_language_codes"` GcpMaxAlternatives int32 `ini:"gcp_max_alternatives"` GcpProfanityFilter bool `ini:"gcp_profanity_filter"` GcpEnableWordTimeOffsets bool `ini:"gcp_enable_word_time_offsets"` GcpEnableWordConfidence bool `ini:"gcp_enable_word_confidence"` GcpEnableAutomaticPunctuation bool `ini:"gcp_enable_automatic_punctuation"` GcpEnableSpokenPunctuation bool `ini:"gcp_enable_spoken_punctuation"` GcpEnableSpokenEmojis bool `ini:"gcp_enable_spoken_emojis"` GcpModel string `ini:"gcp_model"` GcpUseEnhanced bool `ini:"gcp_use_enhanced"` GcpSingleUtterance bool `ini:"gcp_single_utterance"` GcpInterimResults bool `ini:"gcp_interim_results"` // 変換結果に含める項目の有無の指定 GcpResultIsFinal bool `ini:"gcp_result_is_final"` GcpResultStability bool `ini:"gcp_result_stability"` }
type GcpResult ¶
type GcpResult struct { IsFinal *bool `json:"is_final,omitempty"` Stability *float32 `json:"stability,omitempty"` TranscriptionResult }
func NewGcpResult ¶
func NewGcpResult() GcpResult
func (*GcpResult) SetMessage ¶
func (*GcpResult) WithIsFinal ¶
func (*GcpResult) WithStability ¶
type OggWriter ¶
type OggWriter struct {
// contains filtered or unexported fields
}
OggWriter is used to take RTP packets and write them to an OGG on disk
type PacketDumpHandler ¶
type PacketDumpHandler struct { Config Config ChannelID string ConnectionID string SampleRate uint32 ChannelCount uint16 LanguageCode string RetryCount int OnResultFunc func(context.Context, io.WriteCloser, string, string, string, any) error // contains filtered or unexported fields }
func (*PacketDumpHandler) GetRetryCount ¶
func (h *PacketDumpHandler) GetRetryCount() int
func (*PacketDumpHandler) Handle ¶
func (h *PacketDumpHandler) Handle(ctx context.Context, reader io.Reader) (*io.PipeReader, error)
func (*PacketDumpHandler) ResetRetryCount ¶
func (h *PacketDumpHandler) ResetRetryCount() int
func (*PacketDumpHandler) UpdateRetryCount ¶
func (h *PacketDumpHandler) UpdateRetryCount() int
type PacketDumpResult ¶
type PacketDumpResult struct { Timestamp int64 `json:"timestamp"` ChannelID string `json:"channel_id"` ConnectionID string `json:"connection_id"` LanguageCode string `json:"language_code"` SampleRate uint32 `json:"sample_rate"` ChannelCount uint16 `json:"channel_count"` Payload []byte `json:"payload"` }
type RecognitionConfig ¶
type RecognitionConfig struct { Encoding speechpb.RecognitionConfig_AudioEncoding SampleRateHertz int32 AudioChannelCount int32 EnableSeparateRecognitionPerChannel bool LanguageCode string AlternativeLanguageCodes []string MaxAlternatives int32 ProfanityFilter bool SpeechContexts []*speechpb.SpeechContext EnableWordTimeOffsets bool EnableWordConfidence bool EnableAutomaticPunctuation bool EnableSpokenPunctuation bool EnableSpokenEmojis bool Model string UseEnhanced bool }
func NewRecognitionConfig ¶
func NewRecognitionConfig(c Config, languageCode string, sampleRate, channelCount int32) RecognitionConfig
type SpeechToText ¶
func NewSpeechToText ¶
func NewSpeechToText(config Config, languageCode string, sampleRate, channelCount int32) SpeechToText
func (SpeechToText) Start ¶
func (stt SpeechToText) Start(ctx context.Context, r io.Reader) (speechpb.Speech_StreamingRecognizeClient, error)
type SpeechToTextHandler ¶
type SpeechToTextHandler struct { Config Config ChannelID string ConnectionID string SampleRate uint32 ChannelCount uint16 LanguageCode string RetryCount int OnResultFunc func(context.Context, io.WriteCloser, string, string, string, any) error // contains filtered or unexported fields }
func (*SpeechToTextHandler) GetRetryCount ¶
func (h *SpeechToTextHandler) GetRetryCount() int
func (*SpeechToTextHandler) Handle ¶
func (h *SpeechToTextHandler) Handle(ctx context.Context, reader io.Reader) (*io.PipeReader, error)
func (*SpeechToTextHandler) ResetRetryCount ¶
func (h *SpeechToTextHandler) ResetRetryCount() int
func (*SpeechToTextHandler) UpdateRetryCount ¶
func (h *SpeechToTextHandler) UpdateRetryCount() int
type TestHandler ¶
type TestHandler struct { Config Config ChannelID string ConnectionID string SampleRate uint32 ChannelCount uint16 LanguageCode string RetryCount int OnResultFunc func(context.Context, io.WriteCloser, string, string, string, any) error // contains filtered or unexported fields }
func (*TestHandler) GetRetryCount ¶
func (h *TestHandler) GetRetryCount() int
func (*TestHandler) Handle ¶
func (h *TestHandler) Handle(ctx context.Context, reader io.Reader) (*io.PipeReader, error)
func (*TestHandler) ResetRetryCount ¶
func (h *TestHandler) ResetRetryCount() int
func (*TestHandler) UpdateRetryCount ¶
func (h *TestHandler) UpdateRetryCount() int
type TestResult ¶
type TestResult struct { ChannelID *string `json:"channel_id,omitempty"` TranscriptionResult }
func NewTestResult ¶
func NewTestResult(channelID, message string) TestResult
type TranscriptionResult ¶
type TranscriptionResult struct { Message string `json:"message,omitempty"` Reason string `json:"reason,omitempty"` Type string `json:"type"` }
func NewSuzuErrorResponse ¶
func NewSuzuErrorResponse(err error) TranscriptionResult
Source Files ¶
Click to show internal directories.
Click to hide internal directories.