Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doc comments #24

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions NeMoOnnxSharp.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,35 @@ static async Task Main(string[] args)

if (task == "transcribe")
{
await Transcribe();
await TranscribeAsync();
}
else if (task == "speak")
{
await Speak();
await SpeakAsync();
}
else if (task == "vad")
{
await FramePredict(false);
await FramePredictAsync(false);
}
else if (task == "mbn")
{
await FramePredict(true);
await FramePredictAsync(true);
}
else if (task == "streamaudio")
{
await StreamAudio();
await StreamAudioAsync();
}
else
{
throw new InvalidDataException(task);
}
}

static async Task Transcribe()
/// <summary>
/// Using EncDecCTCModel with QuartzNet to transcribe texts from speech audio.
/// </summary>
/// <returns></returns>
static async Task TranscribeAsync()
{
string appDirPath = AppDomain.CurrentDomain.BaseDirectory;
string modelPath = await DownloadModelAsync("stt_en_quartznet15x5");
Expand All @@ -68,7 +72,12 @@ static async Task Transcribe()
}
}

static async Task Speak()
/// <summary>
/// Use high level API SpeechSynthesizer with FastSpeech and HifiGAN
/// </summary>
/// <returns></returns>
/// <exception cref="InvalidDataException"></exception>
static async Task SpeakAsync()
{
string appDirPath = AppDomain.CurrentDomain.BaseDirectory;
string phonemeDict = await DownloadModelAsync("cmudict-0.7b_nv22.10");
Expand Down Expand Up @@ -106,7 +115,12 @@ static async Task Speak()
}
}

static async Task FramePredict(bool mbn)
/// <summary>
/// Use EncDecClassficationModel with MarbleNet for VAD or speech classification
/// </summary>
/// <param name="mbn"></param>
/// <returns></returns>
static async Task FramePredictAsync(bool mbn)
{
string appDirPath = AppDomain.CurrentDomain.BaseDirectory;
string modelPath = await DownloadModelAsync(
Expand Down Expand Up @@ -135,13 +149,16 @@ static async Task FramePredict(bool mbn)
}
}

static async Task StreamAudio()
/// <summary>
/// Use high level API SpeechRecognizer with MarbleNet and QuartzNet
/// </summary>
/// <returns></returns>
static async Task StreamAudioAsync()
{
string appDirPath = AppDomain.CurrentDomain.BaseDirectory;
string vadModelPath = await DownloadModelAsync("vad_marblenet");
string asrModelPath = await DownloadModelAsync("stt_en_quartznet15x5");
string inputDirPath = Path.Combine(appDirPath, "..", "..", "..", "..", "test_data");
string inputPath = Path.Combine(inputDirPath, "transcript.txt");

var config = new SpeechConfig
{
Expand Down