@@ -10,8 +10,10 @@ import { AnchorIcon, FolderIcon, MicrophoneIcon } from "./Icons";
10
10
import { Modal } from "./Modal" ;
11
11
import { Switch } from "./Switch" ;
12
12
import { UrlInput } from "./UrlInput" ;
13
- import { Transcriber } from "../hooks/useTranscriber" ;
14
13
import { titleCase } from "../utils/StringUtils" ;
14
+ import { Transcriber } from "../hooks/useTranscriber" ;
15
+ import { useProtocolHandler } from "../hooks/useProtocolHandler" ;
16
+ import { useAudioFileReceiver } from "../hooks/useAudioFileReceiver" ;
15
17
import { SAMPLING_RATE , DEFAULT_AUDIO_URL , LANGUAGES , MODELS } from "../config" ;
16
18
17
19
export enum AudioSource {
@@ -116,6 +118,18 @@ export const AudioManager: React.FC<AudiomanagerProps> = ({ transcriber }) => {
116
118
}
117
119
} ;
118
120
121
+ // Handle requests to http://localhost:5173/transcribe/?url=
122
+ useProtocolHandler ( "web+transcribe" , ( url : URL ) => {
123
+ const incomingUrl = url . toString ( ) ;
124
+ setAudioDownloadUrl ( incomingUrl ) ;
125
+ } ) ;
126
+
127
+ useAudioFileReceiver ( async ( file ) => {
128
+ const arrayBuffer = await file . arrayBuffer ( ) ;
129
+ const mimeType = file . type ;
130
+ await setAudioFromDownload ( arrayBuffer , mimeType ) ;
131
+ } ) ;
132
+
119
133
// When URL changes, download audio
120
134
useEffect ( ( ) => {
121
135
if ( audioDownloadUrl ) {
0 commit comments