File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
src/components/models/code Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,39 @@ export default {
3737} satisfies ExportedHandler<Env>;
3838` ;
3939
40+ const workers = ` import { Buffer } from 'node:buffer';
41+
42+ export interface Env {
43+ AI: Ai;
44+ }
45+
46+ const URL = "https://pub-dbcf9f0bd3af47ca9d40971179ee62de.r2.dev/02f6edc0-1f7b-4272-bd17-f05335104725/audio.mp3";
47+
48+ export default {
49+ async fetch(request, env, ctx): Promise<Response> {
50+
51+ const mp3 = await fetch(URL);
52+ if (!mp3.ok) {
53+ throw new Error( ` Response status : $ {mp3.status }` );
54+ }
55+ const mp3Buffer = await mp3.arrayBuffer();
56+ const base64 = Buffer.from(mp3Buffer, 'binary').toString("base64");
57+
58+ try {
59+ const res = await env.AI.run("@cf/openai/whisper-large-v3-turbo", {
60+ "audio": base64
61+ });
62+
63+ return Response.json(res);
64+ }
65+ catch (e) {
66+ console.log(JSON.stringify(env.AI));
67+ }
68+ return new Response(JSON.stringify({ho:"to"}));
69+ },
70+ } satisfies ExportedHandler<Env>
71+ ` ;
72+
4073const curl = `
4174curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/${name } \\
4275 -X POST \\
You can’t perform that action at this time.
0 commit comments