Skip to content

[FEATURE]: Clean Up Temporary Audio Files After Transcription #19

@dhruvi-16-me

Description

@dhruvi-16-me

Feature and its Use Cases

Problem

The application records audio consultations and stores them temporarily on the device using path_provider and record. A new audio file is created for every recording session.

Example from lib/main.dart:

final directory = await getTemporaryDirectory();
_recordingPath =
    '${directory.path}/recording_${DateTime.now().millisecondsSinceEpoch}.m4a';

This file is later used for transcription:

final file = File(_recordingPath);

if (!await file.exists()) {
  return;
}

final bytes = await file.readAsBytes();
final response = await http.post(...);

However, after transcription is completed, the recorded audio file is never deleted.

A search across the repository shows no usage of:

File.delete()
deleteSync()

As a result, each consultation leaves behind a temporary audio file.

Over time, this can lead to:

  • accumulation of unused audio files
  • unnecessary device storage usage
  • degraded app performance due to large temporary storage

Proposed Solution

Delete the temporary audio file after the transcription process finishes.

Example implementation:

try {
  final file = File(_recordingPath);
  if (await file.exists()) {
    await file.delete();
  }
} catch (_) {
  // ignore cleanup failures
}

This cleanup should occur after transcription completes, regardless of whether the API request succeeds or fails.

Suggested location:

  • at the end of _transcribeAudio() in lib/main.dart
  • also in any early-return paths where a file may have been created

Expected Outcome

  • Temporary audio files are removed after each transcription
  • Device storage remains clean
  • Prevents long-term accumulation of unused files

Additional Context

No response

Code of Conduct

  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions