Skip to content

Commit 323d6bf

Browse files
committed
Add some docstrings
1 parent a774a4b commit 323d6bf

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

TransformersSharp.Tests/TransformerEnvironment.Test.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void TextToAudioPipeline_Generate()
141141
public void AutomaticSpeechRecognitionPipeline_Transcribe()
142142
{
143143
var pipeline = AutomaticSpeechRecognitionPipeline.FromModel("openai/whisper-tiny");
144-
var audioPath = "https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/1.flac"; // Replace with a valid audio path
144+
var audioPath = "https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/1.flac";
145145
var result = pipeline.Transcribe(audioPath);
146146
Assert.NotNull(result);
147147
Assert.NotEmpty(result);

TransformersSharp/MEAI/SpeechToTextClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static SpeechToTextClient FromModel(string model, TorchDtype? torchDtype
1818

1919
public void Dispose()
2020
{
21-
// Nothing to do right now
21+
// Nothing to do right now. ASR pipeline object will be collected via next GC pass anyway.
2222
}
2323

2424
public object? GetService(Type serviceType, object? serviceKey = null) =>

TransformersSharp/python/transformers_wrapper.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,26 @@ def invoke_text_to_audio_pipeline(pipeline: Pipeline,
157157

158158
def invoke_automatic_speech_recognition_pipeline(pipeline: Pipeline, audio: str) -> str:
159159
"""
160-
Invoke an automatic speech recognition pipeline.
160+
Invoke an automatic speech recognition pipeline and return the result.
161+
162+
Args:
163+
pipeline: The ASR pipeline object
164+
audio: A local file path or a URL
165+
Returns:
166+
The text detected
161167
"""
162168
r = pipeline(audio, return_timestamps=False)
163169
return r['text']
164170

165171
def invoke_automatic_speech_recognition_pipeline_from_bytes(pipeline: Pipeline, audio: bytes) -> str:
166172
"""
167-
Invoke an automatic speech recognition pipeline.
173+
Invoke an automatic speech recognition pipeline and return the result.
174+
175+
Args:
176+
pipeline: The ASR pipeline object
177+
audio: The bytes of the audio file
178+
Returns:
179+
The text detected
168180
"""
169181
r = pipeline(audio, return_timestamps=False)
170182
return r['text']

0 commit comments

Comments
 (0)