Conversation
There was a problem hiding this comment.
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
DetectionApiClientfor a unifiedDemoApiClientthat 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
urlis too generic. Rename to something likeSampleImageUrlto clarify its purpose.
private const string url = "https://raw.githubusercontent.com/.../dog.jpg";
Demo/TransformersSharpWebDemo.ApiService/Program.cs:38
- New
/transcribeendpoint 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-typednew().
List<DetectionResult>? detectedObjects = [];
| // Extend timeout because this can take a while | ||
| httpClient.Timeout = TimeSpan.FromMinutes(5); | ||
| var response = await httpClient.PostAsJsonAsync("/detect", detectRequest, cancellationToken); |
There was a problem hiding this comment.
Overriding HttpClient.Timeout per request can have unintended side effects. Consider configuring a named client or using a cancellation token with a timeout instead.
| // 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); |
| color: yellow; | ||
| border: 5px dotted red; | ||
| font-size: 3em; | ||
| font-family: "Arial"; | ||
| } |
There was a problem hiding this comment.
[nitpick] Inline CSS with hardcoded styles and magic values can hinder maintainability. Consider moving these styles into a CSS class or stylesheet.
| 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; | |
| } |
No description provided.