fix: use temp directory path for audio recording instead of empty string

The record package requires a valid file path. Empty string caused
ENOENT (No such file or directory) on Android.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-24 05:39:07 -08:00
parent 5d4fd96d43
commit d4783a3497
1 changed files with 5 additions and 1 deletions

View File

@ -5,6 +5,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:dio/dio.dart';
import 'package:record/record.dart';
import 'package:flutter_sound/flutter_sound.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart' as p;
import '../../../../core/network/dio_client.dart';
/// Temporary voice I/O test page TTS + STT + Round-trip.
@ -119,6 +121,8 @@ class _VoiceTestPageState extends ConsumerState<VoiceTestPage> {
_rtResult = '';
}
});
final dir = await getTemporaryDirectory();
final filePath = p.join(dir.path, 'voice_test_${DateTime.now().millisecondsSinceEpoch}.wav');
await _recorder.start(
const RecordConfig(
encoder: AudioEncoder.wav,
@ -126,7 +130,7 @@ class _VoiceTestPageState extends ConsumerState<VoiceTestPage> {
numChannels: 1,
bitRate: 256000,
),
path: '', // temp file
path: filePath,
);
}