Capture dictation/TTS debug audio and show dictation errors
This commit is contained in:
@@ -136,12 +136,13 @@ export function DictationOverlay({
|
||||
isRecording,
|
||||
isProcessing,
|
||||
status,
|
||||
errorText,
|
||||
onCancel,
|
||||
onAccept,
|
||||
onAcceptAndSend,
|
||||
onRetry,
|
||||
onDiscard,
|
||||
}: Omit<DictationControlsProps, "onStart" | "disabled">) {
|
||||
}: Omit<DictationControlsProps, "onStart" | "disabled"> & { errorText?: string }) {
|
||||
const { theme } = useUnistyles();
|
||||
const isFailed = status === "failed";
|
||||
const showActiveState = isRecording || isProcessing || isFailed;
|
||||
@@ -199,6 +200,17 @@ export function DictationOverlay({
|
||||
{transcript}
|
||||
</Text>
|
||||
)}
|
||||
{isFailed ? (
|
||||
<Text
|
||||
numberOfLines={2}
|
||||
style={[
|
||||
overlayStyles.transcriptText,
|
||||
{ color: theme.colors.palette.white, opacity: 0.95 },
|
||||
]}
|
||||
>
|
||||
{errorText ? `Dictation failed: ${errorText}` : "Dictation failed. Tap retry."}
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
<View style={overlayStyles.actionButtonsContainer}>
|
||||
|
||||
@@ -199,6 +199,7 @@ export const MessageInput = forwardRef<MessageInputRef, MessageInputProps>(
|
||||
partialTranscript: dictationPartialTranscript,
|
||||
volume: dictationVolume,
|
||||
duration: dictationDuration,
|
||||
error: dictationError,
|
||||
status: dictationStatus,
|
||||
startDictation,
|
||||
cancelDictation,
|
||||
@@ -631,6 +632,7 @@ export const MessageInput = forwardRef<MessageInputRef, MessageInputProps>(
|
||||
isRecording={isDictating}
|
||||
isProcessing={isDictationProcessing}
|
||||
status={dictationStatus}
|
||||
errorText={dictationStatus === "failed" ? dictationError ?? undefined : undefined}
|
||||
onCancel={handleCancelRecording}
|
||||
onAccept={handleAcceptRecording}
|
||||
onAcceptAndSend={handleAcceptAndSendRecording}
|
||||
|
||||
@@ -200,6 +200,7 @@ export function useDictation(options: UseDictationOptions): UseDictationResult {
|
||||
const handleStreamingTranscriptionSuccess = useCallback(
|
||||
(text: string, requestId: string) => {
|
||||
setIsProcessing(false);
|
||||
isProcessingRef.current = false;
|
||||
setPartialTranscript("");
|
||||
setDuration(0);
|
||||
setStatus("idle");
|
||||
@@ -220,6 +221,7 @@ export function useDictation(options: UseDictationOptions): UseDictationResult {
|
||||
const normalized = toError(failure);
|
||||
const failureId = generateMessageId();
|
||||
setIsProcessing(false);
|
||||
isProcessingRef.current = false;
|
||||
isRecordingRef.current = false;
|
||||
setIsRecording(false);
|
||||
|
||||
@@ -447,9 +449,14 @@ export function useDictation(options: UseDictationOptions): UseDictationResult {
|
||||
stopDurationTracking();
|
||||
setDuration(0);
|
||||
setIsProcessing(false);
|
||||
isProcessingRef.current = false;
|
||||
setError(null);
|
||||
setStatus("idle");
|
||||
clearStreamingState();
|
||||
if (senderRef.current?.hasSegments()) {
|
||||
setStatus("failed");
|
||||
} else {
|
||||
setStatus("idle");
|
||||
clearStreamingState();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [autoStopWhenHidden?.isVisible, clearStreamingState, stopDurationTracking]);
|
||||
|
||||
Reference in New Issue
Block a user