matt HOFFNER
		
	commited on
		
		
					Commit 
							
							·
						
						7df6d3d
	
1
								Parent(s):
							
							c8758af
								
cleanup
Browse files- app/input.tsx +14 -5
    	
        app/input.tsx
    CHANGED
    
    | @@ -51,21 +51,30 @@ const VoiceInputForm: React.FC<VoiceInputFormProps> = ({ handleSubmit, input, se | |
| 51 |  | 
| 52 | 
             
                const startRecording = async () => {
         | 
| 53 | 
             
                    cleanupRecording(); // Clean up any existing recording resources
         | 
| 54 | 
            -
             | 
| 55 | 
             
                    try {
         | 
| 56 | 
            -
                         | 
| 57 | 
             
                        const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
         | 
| 58 | 
            -
                         | 
| 59 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 60 | 
             
                        mediaRecorderRef.current.ondataavailable = (event: BlobEvent) => {
         | 
| 61 | 
             
                            audioChunksRef.current.push(event.data);
         | 
| 62 | 
             
                        };
         | 
| 63 | 
            -
             | 
| 64 | 
             
                        mediaRecorderRef.current.start();
         | 
| 65 | 
             
                    } catch (err) {
         | 
| 66 | 
             
                        console.error("Error accessing media devices:", err);
         | 
| 67 | 
             
                    }
         | 
| 68 | 
             
                };
         | 
|  | |
| 69 |  | 
| 70 | 
             
                const stopRecording = async (): Promise<Blob> => {
         | 
| 71 | 
             
                    return new Promise((resolve, reject) => {
         | 
|  | |
| 51 |  | 
| 52 | 
             
                const startRecording = async () => {
         | 
| 53 | 
             
                    cleanupRecording(); // Clean up any existing recording resources
         | 
| 54 | 
            +
                
         | 
| 55 | 
             
                    try {
         | 
| 56 | 
            +
                        // Simplified constraints for broader compatibility
         | 
| 57 | 
             
                        const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
         | 
| 58 | 
            +
                        let recorderOptions = {};
         | 
| 59 | 
            +
                
         | 
| 60 | 
            +
                        // Check if the mimeType is supported; if so, use it
         | 
| 61 | 
            +
                        const mimeType = getMimeType();
         | 
| 62 | 
            +
                        if (mimeType && MediaRecorder.isTypeSupported(mimeType)) {
         | 
| 63 | 
            +
                            recorderOptions = { mimeType };
         | 
| 64 | 
            +
                        }
         | 
| 65 | 
            +
                
         | 
| 66 | 
            +
                        mediaRecorderRef.current = new MediaRecorder(stream, recorderOptions);
         | 
| 67 | 
            +
                
         | 
| 68 | 
             
                        mediaRecorderRef.current.ondataavailable = (event: BlobEvent) => {
         | 
| 69 | 
             
                            audioChunksRef.current.push(event.data);
         | 
| 70 | 
             
                        };
         | 
| 71 | 
            +
                
         | 
| 72 | 
             
                        mediaRecorderRef.current.start();
         | 
| 73 | 
             
                    } catch (err) {
         | 
| 74 | 
             
                        console.error("Error accessing media devices:", err);
         | 
| 75 | 
             
                    }
         | 
| 76 | 
             
                };
         | 
| 77 | 
            +
                
         | 
| 78 |  | 
| 79 | 
             
                const stopRecording = async (): Promise<Blob> => {
         | 
| 80 | 
             
                    return new Promise((resolve, reject) => {
         | 
