import { useAudioRecorder, RecordingPresets } from 'expo-audio';

export function useVoiceRecorder() {
  const recorder = useAudioRecorder(RecordingPresets.HIGH_QUALITY);

  return {
    recorder,
    async start() {
      await recorder.prepareToRecordAsync();
      recorder.record();
    },
    async stop() {
      await recorder.stop();
      return recorder.uri;
    },
  };
}

export async function transcribeVoice(uri: string) {
  // 后续接入 /api/v1/mobile/voice/transcribe；初始化阶段先返回可见占位结果。
  return {
    text: `已收到语音文件：${uri.split('/').pop() || 'voice-recording'}`,
    confidence: 0,
  };
}
