refactor: extract Deepgram API call into TranscriptionService#17
refactor: extract Deepgram API call into TranscriptionService#17SISIR-REDDY wants to merge 1 commit intoAOSSIE-Org:mainfrom
Conversation
Closes AOSSIE-Org#11 main.dart previously mixed UI state, audio recording, Deepgram HTTP calls, and Gemini processing in a single 500-line file. This commit starts separating those concerns by pulling the Deepgram integration into its own service class. - Add lib/services/transcription_service.dart TranscriptionService owns the Deepgram HTTP call, timeout, and response parsing. Introduces TranscriptionResult (success/failure) so callers do not need to parse raw HTTP status codes. hasValidApiKey rejects empty and placeholder values. All logging goes through developer.log() with a named tag. - Update lib/main.dart Instantiate TranscriptionService alongside ChatbotService. Replace the inline _transcribeAudio() HTTP block with a single call to _transcriptionService.transcribe(). Remove now-unused imports: dart:convert, dart:io, package:http, package:flutter_markdown.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I have already did the changes in PR#12 , please refer it ! |
|
Please resolve the merge conflicts before review. Your PR will only be reviewed by a maintainer after all conflicts have been resolved. 📺 Watch this video to understand why conflicts occur and how to resolve them: |
|
Hey @SharkyBytes This PR is not needed anymore. This was handled in PR #12. This is a duplicate PR. Since this is not needed I am closing it. |
Closes #11
Problem
As noted in #11,
main.dartwas doing too many things at once — managing UI state, handling audio recording, making raw Deepgram HTTP requests, and orchestrating Gemini processing, all in a single 500-line file. This made the Deepgram logic untestable in isolation and harder to change without touching the UI.Changes
lib/services/transcription_service.dart(new file)TranscriptionServicetakes sole ownership of the Deepgram integration:transcribe(filePath)handles reading the file, POSTing to the Deepgram Nova-2 endpoint, parsing the response, and mapping errors to human-readable messages.TranscriptionResultvalue object (success/failure) so the caller never has to inspect HTTP status codes.hasValidApiKeyrejects empty and placeholder key values before any network call is made.developer.log()with theTranscriptionServicetag.lib/main.dart_TranscriptionScreenStatenow instantiatesTranscriptionServicealongsideChatbotService._transcribeAudio()is reduced from ~50 lines of HTTP boilerplate to a singleawait _transcriptionService.transcribe(_recordingPath)call followed by straightforward state updates based onresult.isSuccess.dart:convert,dart:io,package:http/http.dart,package:flutter_markdown/flutter_markdown.dart.What was intentionally left for follow-up
The audio recording logic (
_startRecording,_stopRecording,AudioRecorder) still lives in the widget. Extracting that is a larger change — aRecordingServicewould be a natural next step, but keeping this PR focused makes it easier to review.