Skip to content

Add ASR pipelines to the demo#6

Merged
tonybaloney merged 8 commits intomainfrom
asr
May 20, 2025
Merged

Add ASR pipelines to the demo#6
tonybaloney merged 8 commits intomainfrom
asr

Conversation

@tonybaloney
Copy link
Copy Markdown
Owner

No description provided.

@tonybaloney tonybaloney requested a review from Copilot May 20, 2025 21:38
@tonybaloney tonybaloney merged commit 8d82002 into main May 20, 2025
1 check passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the web demo by consolidating detection and transcription into a single client, adding an ASR page, and extending the backend API with a /transcribe endpoint.

  • Swap out DetectionApiClient for a unified DemoApiClient that handles both detection and transcription.
  • Introduce a new Transcribe page, navigation entry, and client method for FLAC audio uploads.
  • Add a speech-to-text pipeline in the API service and expose it via /transcribe.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Demo/TransformersSharpWebDemo.Web/Program.cs Register DemoApiClient instead of the old detection client
Demo/TransformersSharpWebDemo.Web/DetectionApiClient.cs Remove standalone detection client (superseded)
Demo/TransformersSharpWebDemo.Web/DemoApiClient.cs New combined client with object detection and transcription methods, extended timeout
Demo/TransformersSharpWebDemo.Web/Components/Pages/Transcribe.razor New ASR UI page for uploading and transcribing FLAC files
Demo/TransformersSharpWebDemo.Web/Components/Pages/ObjectDetection.razor Switch to DemoApiClient, update sample image URL, adjust inline styles
Demo/TransformersSharpWebDemo.Web/Components/Layout/NavMenu.razor Shorten branding text, add ASR menu entry
Demo/TransformersSharpWebDemo.ApiService/Program.cs Register Whisper-based speech-to-text client and map /transcribe endpoint
Comments suppressed due to low confidence (4)

Demo/TransformersSharpWebDemo.Web/Components/Pages/Transcribe.razor:42

  • [nitpick] The error message is terse and lowercase. Consider a clearer, more user-friendly message like "Selected file must be a FLAC audio file."
error = "Must be flac";

Demo/TransformersSharpWebDemo.Web/Components/Pages/ObjectDetection.razor:45

  • [nitpick] The constant name url is too generic. Rename to something like SampleImageUrl to clarify its purpose.
private const string url = "https://raw.githubusercontent.com/.../dog.jpg";

Demo/TransformersSharpWebDemo.ApiService/Program.cs:38

  • New /transcribe endpoint is added without corresponding tests. Consider adding integration or unit tests to verify file uploads and transcription responses.
app.MapPost("/transcribe", async (HttpRequest request) =>

Demo/TransformersSharpWebDemo.Web/DemoApiClient.cs:10

  • The list initialization using [] is invalid for a List. Replace with new List<DetectionResult>() or use a target-typed new().
List<DetectionResult>? detectedObjects = [];

Comment on lines +13 to +15
// Extend timeout because this can take a while
httpClient.Timeout = TimeSpan.FromMinutes(5);
var response = await httpClient.PostAsJsonAsync("/detect", detectRequest, cancellationToken);
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overriding HttpClient.Timeout per request can have unintended side effects. Consider configuring a named client or using a cancellation token with a timeout instead.

Suggested change
// Extend timeout because this can take a while
httpClient.Timeout = TimeSpan.FromMinutes(5);
var response = await httpClient.PostAsJsonAsync("/detect", detectRequest, cancellationToken);
// Use a cancellation token with a timeout for this request
using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
cts.CancelAfter(TimeSpan.FromMinutes(5));
var response = await httpClient.PostAsJsonAsync("/detect", detectRequest, cts.Token);

Copilot uses AI. Check for mistakes.
Comment on lines +17 to 21
color: yellow;
border: 5px dotted red;
font-size: 3em;
font-family: "Arial";
}
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Inline CSS with hardcoded styles and magic values can hinder maintainability. Consider moving these styles into a CSS class or stylesheet.

Suggested change
color: yellow;
border: 5px dotted red;
font-size: 3em;
font-family: "Arial";
}
font-size: 3em;
font-family: "Arial";
}
.detection-label {
color: yellow;
border: 5px dotted red;
}

Copilot uses AI. Check for mistakes.
@tonybaloney tonybaloney deleted the asr branch June 25, 2025 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants