From 76eedc1396b1e59980677372f4121aee6638fbc7 Mon Sep 17 00:00:00 2001 From: Markus Hennerbichler Date: Thu, 7 Sep 2023 10:37:21 +0000 Subject: [PATCH] Fix warnings and bump version --- SmRtAPI/SmRtAPI/Config/PunctuationConfig.cs | 10 ++++++++++ SmRtAPI/SmRtAPI/Config/SmRtApiConfig.cs | 15 +++++++++++++++ .../SmRtAPI/Config/SpeakerDiarizationConfig.cs | 3 +++ SmRtAPI/SmRtAPI/Config/TranslationConfig.cs | 11 +++++++++++ SmRtAPI/SmRtAPI/Enumerations/DiarizationType.cs | 9 +++++++++ SmRtAPI/SmRtAPI/MessageWriter.cs | 4 ++-- .../Messages/AddPartialTranslationMessage.cs | 2 +- SmRtAPI/SmRtAPI/Messages/AddTranslationMessage.cs | 4 +++- SmRtAPI/SmRtAPI/SmRtApiConfigBase.cs | 3 +++ SmRtAPI/Speechmatics.nuspec | 2 +- 10 files changed, 58 insertions(+), 5 deletions(-) diff --git a/SmRtAPI/SmRtAPI/Config/PunctuationConfig.cs b/SmRtAPI/SmRtAPI/Config/PunctuationConfig.cs index e00b4e1..497d1c5 100644 --- a/SmRtAPI/SmRtAPI/Config/PunctuationConfig.cs +++ b/SmRtAPI/SmRtAPI/Config/PunctuationConfig.cs @@ -4,10 +4,20 @@ namespace Speechmatics.Realtime.Client.Config { + + /// + /// Configuration for customizing punctuation + /// public class PunctuationConfig { + /// + /// List of permitted punctuation marks + /// public IEnumerable? PermittedMarks { get; set; } + /// + /// Punctuation detection sensitivity, higher values will produce more punctuation, the default is 0.5 + /// public double? Sensitivity { get; set; } } } diff --git a/SmRtAPI/SmRtAPI/Config/SmRtApiConfig.cs b/SmRtAPI/SmRtAPI/Config/SmRtApiConfig.cs index f249250..c238b21 100644 --- a/SmRtAPI/SmRtAPI/Config/SmRtApiConfig.cs +++ b/SmRtAPI/SmRtAPI/Config/SmRtApiConfig.cs @@ -4,6 +4,9 @@ namespace Speechmatics.Realtime.Client.Config { + /// + /// Configuration for an RT API session + /// public class SmRtApiConfig : SmRtApiConfigBase { /// @@ -26,10 +29,22 @@ public class SmRtApiConfig : SmRtApiConfigBase /// public Action AddTranslationMessageCallback { get; set; } + /// + /// Create new config for a given language, + /// specifying input audio details + /// + /// + /// + /// + /// public SmRtApiConfig(string model, int sampleRate, AudioFormatType audioFormatType, AudioFormatEncoding audioFormatEncoding) : base(model, sampleRate, audioFormatType, audioFormatEncoding) { } + /// + /// Create transcription config for the specified language + /// + /// public SmRtApiConfig(string model) : base(model) { } diff --git a/SmRtAPI/SmRtAPI/Config/SpeakerDiarizationConfig.cs b/SmRtAPI/SmRtAPI/Config/SpeakerDiarizationConfig.cs index db651ea..000b0e7 100644 --- a/SmRtAPI/SmRtAPI/Config/SpeakerDiarizationConfig.cs +++ b/SmRtAPI/SmRtAPI/Config/SpeakerDiarizationConfig.cs @@ -4,6 +4,9 @@ namespace Speechmatics.Realtime.Client.Config { + /// + /// Additional configuration for diarization + /// public class SpeakerDiarizationConfig { /// diff --git a/SmRtAPI/SmRtAPI/Config/TranslationConfig.cs b/SmRtAPI/SmRtAPI/Config/TranslationConfig.cs index 8be17ac..c88c73b 100644 --- a/SmRtAPI/SmRtAPI/Config/TranslationConfig.cs +++ b/SmRtAPI/SmRtAPI/Config/TranslationConfig.cs @@ -5,9 +5,20 @@ namespace Speechmatics.Realtime.Client.Config { + /// + /// Additional configuration for translation + /// public class TranslationConfig { + + /// + /// List of target languages to translate to + /// public IEnumerable TargetLanguages { get; set; } + /// + /// Flag for enabling translation partials. + /// These are based on transcription partials and thus subject to change. + /// public bool EnablePartials { get; set; } = false; } diff --git a/SmRtAPI/SmRtAPI/Enumerations/DiarizationType.cs b/SmRtAPI/SmRtAPI/Enumerations/DiarizationType.cs index 6ace66b..fe31c71 100644 --- a/SmRtAPI/SmRtAPI/Enumerations/DiarizationType.cs +++ b/SmRtAPI/SmRtAPI/Enumerations/DiarizationType.cs @@ -4,9 +4,18 @@ namespace Speechmatics.Realtime.Client.Enumerations { + /// + /// Specifying the type of diarization for this session + /// public enum DiarizationType { + /// + /// No diarization + /// None, + /// + /// Speaker diarization + /// Speaker, } } diff --git a/SmRtAPI/SmRtAPI/MessageWriter.cs b/SmRtAPI/SmRtAPI/MessageWriter.cs index d881e8e..893e1b5 100644 --- a/SmRtAPI/SmRtAPI/MessageWriter.cs +++ b/SmRtAPI/SmRtAPI/MessageWriter.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Speechmatics.Realtime.Client.Messages; using Speechmatics.Realtime.Client.Interfaces; -using Speechmatics.Realtime.Client.Messages; namespace Speechmatics.Realtime.Client { @@ -15,7 +14,7 @@ internal class MessageWriter { private readonly ClientWebSocket _wsClient; private readonly AutoResetEvent _transcriptionComplete; - private int _sequenceNumber; + private int _sequenceNumber = 0; private readonly Stream _stream; private readonly AutoResetEvent _recognitionStarted; private readonly ISmRtApi _api; @@ -51,6 +50,7 @@ public async Task Start() while ((bytesRead = await _stream.ReadAsync(streamBuffer, 0, streamBuffer.Length)) > 0 && !_transcriptionComplete.WaitOne(0)) { await SendData(new ArraySegment(streamBuffer, 0, bytesRead)); + _sequenceNumber++; } var endOfStream = new EndOfStreamMessage(_sequenceNumber); diff --git a/SmRtAPI/SmRtAPI/Messages/AddPartialTranslationMessage.cs b/SmRtAPI/SmRtAPI/Messages/AddPartialTranslationMessage.cs index 1045444..0aa89fd 100644 --- a/SmRtAPI/SmRtAPI/Messages/AddPartialTranslationMessage.cs +++ b/SmRtAPI/SmRtAPI/Messages/AddPartialTranslationMessage.cs @@ -3,7 +3,7 @@ namespace Speechmatics.Realtime.Client.Messages /// /// A partial translation is a translation that can be changed and expanded by a future AddTranslation or AddPartialTranslation message - // and corresponds to the part of audio since the last AddTranslation message. + /// and corresponds to the part of audio since the last AddTranslation message. /// public class AddPartialTranslationMessage : BaseMessage { diff --git a/SmRtAPI/SmRtAPI/Messages/AddTranslationMessage.cs b/SmRtAPI/SmRtAPI/Messages/AddTranslationMessage.cs index 0a949a3..97c3df2 100644 --- a/SmRtAPI/SmRtAPI/Messages/AddTranslationMessage.cs +++ b/SmRtAPI/SmRtAPI/Messages/AddTranslationMessage.cs @@ -1,6 +1,8 @@ namespace Speechmatics.Realtime.Client.Messages { - + /// + /// Translation final message + /// public class TranslationSubMessage: BaseMessage { /// diff --git a/SmRtAPI/SmRtAPI/SmRtApiConfigBase.cs b/SmRtAPI/SmRtAPI/SmRtApiConfigBase.cs index 76e5078..ecf048b 100644 --- a/SmRtAPI/SmRtAPI/SmRtApiConfigBase.cs +++ b/SmRtAPI/SmRtAPI/SmRtApiConfigBase.cs @@ -146,6 +146,9 @@ public class SmRtApiConfigBase /// public string? Domain { get; set; } + /// + /// Optional configuration for Translation + /// public TranslationConfig? TranslationConfig { get; set; } /// diff --git a/SmRtAPI/Speechmatics.nuspec b/SmRtAPI/Speechmatics.nuspec index 91b6fd3..d0b2566 100644 --- a/SmRtAPI/Speechmatics.nuspec +++ b/SmRtAPI/Speechmatics.nuspec @@ -2,7 +2,7 @@ Speechmatics - 1.1.0 + 1.1.1 Speechmatics Speechmatics docs/README.md