The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.
Studio: add Xiaomi MiMo transcription and voice-over (#261)
LiuJie1b2ce6477455
diff --git a/.changeset/mimo-speech-recognition.md b/.changeset/mimo-speech-recognition.mdnew file mode 100644index 0000000..6fda791--- /dev/null+++ b/.changeset/mimo-speech-recognition.md@@ -0,0 +1,5 @@+---+"openfilm": patch+---++Xiaomi MiMo writes down what is said, for subtitles, and speaks a line, with your own key: connect one in Studio (the OpenFilm logo at the top left → Providers) or set `MIMO_API_KEY`, then choose Xiaomi MiMo for transcripts or voice-over, or run `openfilm get asr --via mimo --src assets/talk.mp4` and `openfilm get tts --via mimo --out intro --text "…" --voice Chloe`. Its speech recognition times no words: the transcript's lines spread over the recording, and Studio cuts them into subtitles as it does any other.diff --git a/packages/openfilm/studio/server/get.mjs b/packages/openfilm/studio/server/get.mjsindex f6fbac5..88d31a7 100644--- a/packages/openfilm/studio/server/get.mjs+++ b/packages/openfilm/studio/server/get.mjs@@ -448,9 +448,9 @@ function wordsOf(raw) {}/**- * Land what a provider made: its files under assets/ (nothing else, no `..`), and for speech whose words came timed- * (a voice-over from a service that times them, a transcript), its transcript beside it (transcripts.mjs). A voice-over- * without word times gets none: `get asr` makes it.+ * Land what a provider made: its files under assets/ (nothing else, no `..`), and for speech, its transcript beside it+ * (transcripts.mjs): a voice-over's or a transcript's timed words, or a transcript's own text (a service that times no+ * words), its lines spread over the speech. A voice-over without word times gets none: `get asr` makes it.* @param {string} root @param {string} verb @param {Record<string, unknown>} args @param {RunResult} result*/async function land(root, verb, args, result) {@@ -472,8 +472,9 @@ async function land(root, verb, args, result) {provider's file, under assets/ */const src = verb === 'asr' ? String(args.src) : row?.src;const words = wordsOf(row?.words);- if ((verb === 'tts' && !landable(src)) || !words.length) continue;const text = typeof row.text === 'string' && row.text.trim() ? row.text : words.map((w) => w.token).join(' ');+ /* a voice-over's transcript needs its timed words; a transcript's own text is enough on its own */+ if ((verb === 'tts' && (!landable(src) || !words.length)) || !text) continue;const dur = Number(row.dur);const lines = spokenLines(text, words, Number.isFinite(dur) && dur > 0 ? dur * 1000 : undefined);if (!lines.length) continue;diff --git a/packages/openfilm/studio/server/get.test.mjs b/packages/openfilm/studio/server/get.test.mjsindex cdb909f..1be6dfc 100644--- a/packages/openfilm/studio/server/get.test.mjs+++ b/packages/openfilm/studio/server/get.test.mjs@@ -10,6 +10,7 @@ import { fileURLToPath } from 'node:url';import { filmCaptions, translateFilmSubtitles } from './captions.mjs';import { readTranscript } from './transcripts.mjs';import { VERBS, WEB_VERBS, WHERE_TO_CONNECT, catalog, flagHelp, runGet, services, subtitleTranslator } from './get.mjs';+import { wav } from './providers/common.mjs';import { changeSettings, kindOf, providersFile } from './keys.mjs';import { listProviders } from './providers/index.mjs';import { startStudio } from './server.mjs';@@ -75,7 +76,7 @@ before(async () => {base = `http://127.0.0.1:${service.address().port}`;Object.assign(process.env, {OPENFILM_HOME: join(scratch, 'home'), OPENFILM_LIBRARY: join(scratch, 'library'),- OPENFILM_ELEVENLABS_URL: base, OPENFILM_FAL_URL: base, OPENFILM_OPENAI_URL: base,+ OPENFILM_ELEVENLABS_URL: base, OPENFILM_FAL_URL: base, OPENFILM_OPENAI_URL: base, OPENFILM_MIMO_URL: base,});for (const p of [...listProviders(), { env: 'GOOGLE_API_KEY' }]) delete process.env[p.env];});@@ -272,6 +273,38 @@ test('asr: a recording outside assets/ gets its transcript beside it too; the toassert.equal(calls.filter((c) => c.path === '/v1/speech-to-text').length, 2);});+test('asr: a MiMo transcript lands beside the recording, its words carrying the time each stretch was said', async () => {+ const root = project();+ mkdirSync(join(root, 'assets'), { recursive: true });+ execFileSync('ffmpeg', ['-v', 'error', '-f', 'lavfi', '-i', 'sine=frequency=440:duration=1', join(root, 'assets/talk.wav')]);+ refuse = () => [200, { choices: [{ message: { content: '你好,世界。Hello there.' } }], usage: { seconds: 4 } }];+ const receipt = JSON.parse(await runGet(root, 'asr', { src: 'assets/talk.wav' }, { via: 'mimo' }));+ assert.deepEqual(receipt, { src: 'assets/talk.wav', text: '你好,世界。 Hello there.', transcript: 'assets/talk.vtt' });+ const sent = calls.at(-1);+ const body = JSON.parse(sent.body.toString('utf8'));+ assert.equal(sent.path, '/v1/chat/completions');+ assert.equal(sent.headers['api-key'], 'mimo-test-0123456789');+ assert.equal(body.model, 'mimo-v2.5-asr');+ assert.match(body.messages[0].content[0].input_audio.data, /^data:audio\/mpeg;base64,/);+ /* one line a sentence; each word a timestamp tag inside it, the first of a line the cue's own start */+ const vtt = readFileSync(join(root, 'assets/talk.vtt'), 'utf8');+ assert.match(vtt, /^WEBVTT\n\n00:00:00\.000 --> 00:00:00\.\d{3}\n你<00:00:00\.\d{3}>好,<00:00:00\.\d{3}>世<00:00:00\.\d{3}>界。\n\n00:00:00\.\d{3} --> 00:00:01\.\d{3}\nHello <00:00:00\.\d{3}>there\.\n$/);+ assert.equal(JSON.parse(await runGet(root, 'asr', { src: 'assets/talk.wav' })).skip, true, 'not made twice');+});++test('tts: a line spoken as a chat completion lands as a WAV, with no transcript until asr makes one', async () => {+ const root = project();+ refuse = () => [200, { choices: [{ message: { content: '', audio: { data: Buffer.from(wav(new Uint8Array(32000), 16000)).toString('base64') } } }] }];+ const said = JSON.parse(await runGet(root, 'tts', { out: 'line', text: 'Hello there.', voice: 'Chloe' }, { via: 'mimo' }));+ assert.deepEqual(said, { src: 'assets/audio/vo/line.wav', dur: 1, voiceId: 'Chloe', transcript: 'none: the service does not time words; `get asr --src` makes one' });+ assert.ok(existsSync(join(root, 'assets/audio/vo/line.wav')));+ const body = JSON.parse(calls.at(-1).body.toString('utf8'));+ assert.equal(calls.at(-1).path, '/v1/chat/completions');+ assert.equal(body.model, 'mimo-v2.5-tts');+ assert.deepEqual(body.messages, [{ role: 'assistant', content: 'Hello there.' }]);+ assert.deepEqual(body.audio, { format: 'wav', voice: 'Chloe' });+});+test('what lands stays in assets/, and the receipt leaves out what it cost', async (t) => {const root = project();const fal = listProviders().find((p) => p.id === 'fal');@@ -405,7 +438,7 @@ test('openfilm get: what can be got here, connected, partly or not at all; wrongassert.equal(nothing.stdout, 'Nothing is connected for media here: each kind works only once the person connects a service that makes it (below). '+ 'Until then, make sound and pictures in code, or use a service the person has a key for (with its API docs), and save them under assets/. '+ `\`openfilm get <what> --help\` shows what one kind takes (${media.join(', ')}).\n\n${services()}\n`);- assert.match(services(), /^Media services, each used with the person's own key: Brave Search \(web search\), Doubao \(transcripts\), ElevenLabs \(voice-over, sound effects, music, transcripts\), fal\.ai \(images, video, music, sound effects\), .*, Microsoft Azure \(voice-over\), .*, Tavily \(web search\)\. In Studio, the OpenFilm logo at the top left opens Settings/);+ assert.match(services(), /^Media services, each used with the person's own key: Brave Search \(web search\), Doubao \(transcripts\), ElevenLabs \(voice-over, sound effects, music, transcripts\), fal\.ai \(images, video, music, sound effects\), .*, Microsoft Azure \(voice-over\), .*, Tavily \(web search\), Xiaomi MiMo \(voice-over, transcripts\)\. In Studio, the OpenFilm logo at the top left opens Settings/);/* partly: what is connected, then one line for the rest with the services that make each, then the services thereare; never who makes what is connected */diff --git a/packages/openfilm/studio/server/providers/index.mjs b/packages/openfilm/studio/server/providers/index.mjsindex 032ddb4..7770241 100644--- a/packages/openfilm/studio/server/providers/index.mjs+++ b/packages/openfilm/studio/server/providers/index.mjs@@ -26,6 +26,7 @@ import tavily from './tavily.mjs';import groq from './groq.mjs';import azure from './azure.mjs';import doubao from './doubao.mjs';+import mimo from './mimo.mjs';/*** @typedef {import('./contract.mjs').Provider} Provider @typedef {import('./contract.mjs').Verb} Verb@@ -34,7 +35,7 @@ import doubao from './doubao.mjs';*//** The providers paid with the person's own key. */-const OWN = [elevenlabs, openai, google, fal, pexels, pixabay, brave, tavily, groq, azure, doubao];+const OWN = [elevenlabs, openai, google, fal, pexels, pixabay, brave, tavily, groq, azure, doubao, mimo];/** The kinds of media the person chooses a provider and model for (Settings → Services). */const USE_VERBS = /** @type {Verb[]} */ (['tts', 'music', 'sfx', 'asr', 'image', 'image-search', 'video', 'translate', 'web-search']);diff --git a/packages/openfilm/studio/server/providers/index.test.mjs b/packages/openfilm/studio/server/providers/index.test.mjsindex dab935a..793ec38 100644--- a/packages/openfilm/studio/server/providers/index.test.mjs+++ b/packages/openfilm/studio/server/providers/index.test.mjs@@ -8,14 +8,14 @@ import { chooseProvider, listProviders, shownChoices } from './index.mjs';before(() => {/* this machine's own keys must not decide these */process.env.OPENFILM_HOME = mkdtempSync(join(tmpdir(), 'of-routing-'));- for (const name of ['ELEVENLABS_API_KEY', 'OPENAI_API_KEY', 'GEMINI_API_KEY', 'GOOGLE_API_KEY', 'FAL_KEY', 'PEXELS_API_KEY', 'PIXABAY_API_KEY', 'BRAVE_API_KEY', 'TAVILY_API_KEY', 'GROQ_API_KEY', 'AZURE_SPEECH_KEY', 'DOUBAO_ASR_API_KEY']) delete process.env[name];+ for (const name of ['ELEVENLABS_API_KEY', 'OPENAI_API_KEY', 'GEMINI_API_KEY', 'GOOGLE_API_KEY', 'FAL_KEY', 'PEXELS_API_KEY', 'PIXABAY_API_KEY', 'BRAVE_API_KEY', 'TAVILY_API_KEY', 'GROQ_API_KEY', 'AZURE_SPEECH_KEY', 'DOUBAO_ASR_API_KEY', 'MIMO_API_KEY']) delete process.env[name];});const settings = (keys = {}, use = {}) => ({ keys, use, model: {} });const id = async (promise) => (await promise)?.id ?? null;test('the own-key providers, in the order Settings lists them', () => {- assert.deepEqual(listProviders().map((p) => p.id), ['elevenlabs', 'openai', 'google', 'fal', 'pexels', 'pixabay', 'brave', 'tavily', 'groq', 'azure', 'doubao']);+ assert.deepEqual(listProviders().map((p) => p.id), ['elevenlabs', 'openai', 'google', 'fal', 'pexels', 'pixabay', 'brave', 'tavily', 'groq', 'azure', 'doubao', 'mimo']);});test('nothing serves a kind of media nobody chose, even with a key that could', async () => {diff --git a/packages/openfilm/studio/server/providers/mimo.mjs b/packages/openfilm/studio/server/providers/mimo.mjsnew file mode 100644index 0000000..5ac30cb--- /dev/null+++ b/packages/openfilm/studio/server/providers/mimo.mjs@@ -0,0 +1,225 @@+// @ts-check+/**+ * Xiaomi MiMo with the person's own key: speech recognition (MiMo-V2.5-ASR) and voice-over (MiMo-V2.5-TTS) through+ * the MiMo API (https://platform.xiaomimimo.com/docs). Both are chat completions under /v1/chat/completions with the+ * key in an `api-key` header. A platform key (sk-…) answers at the pay-as-you-go API; a Token Plan key (tp-…) at its+ * gateway (https://token-plan-cn.xiaomimimo.com) — the key says which, so neither is set by hand.+ * OPENFILM_MIMO_URL points both somewhere else (a test server, a proxy).+ *+ * Recognition answers text with no word timings. To keep subtitles honest, the speech is cut at its pauses first+ * (ffmpeg, as `get` already needs it) and each stretch is asked for on its own, so every stretch's words carry the+ * real time it was said in and a pause is a cue boundary; without a pause to cut at, the one answer spreads over the+ * recording. Voice-over sends the line as the assistant's message and answers a WAV in `message.audio.data`, with no+ * word timings either. The voices are the ones the API names; it has no endpoint to list them.+ */+import { execFile } from 'node:child_process';+import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { billedBy, call, clamp, landing, modelOf, needed, noBalance, notes, number, round, serviceUrl, text, wavSeconds, wordsFromCharacters } from './common.mjs';++/** @typedef {import('./contract.mjs').Provider} Provider */++const NAME = 'Xiaomi MiMo';+/** the models it makes each kind of media with, the default first (https://platform.xiaomimimo.com/docs) */+const MODELS = {+ asr: [{ id: 'mimo-v2.5-asr', name: 'MiMo-V2.5-ASR' }],+ tts: [{ id: 'mimo-v2.5-tts', name: 'MiMo-V2.5-TTS' }],+};+/** the voices it speaks with, as the API names them in its errors (no listing endpoint) */+const VOICES = ['mimo_default', '冰糖', '茉莉', '苏打', '白桦', 'Mia', 'Chloe', 'Milo', 'Dean'];+/** the largest speech sent at once */+const MAX_UPLOAD = 100 * 1024 * 1024;+/** how long one request may take (a long stretch, a long line) */+const TIMEOUT_MS = 300_000;+/** a pause at least this long, this quiet, is where the speech is cut */+const CUT_NOISE = '-20dB', CUT_SECONDS = 0.4;+/** a stretch shorter than this is one with its neighbours (a breath between close pauses) */+const MIN_STRETCH = 0.7;+/** the longest stretch asked for at once */+const MAX_STRETCH = 30;++/** Where a key answers: a Token Plan key (tp-…) at its gateway, a platform key (sk-…) at the pay-as-you-go API. */+export const baseFor = (/** @type {string} */ key) =>+ key.startsWith('tp-') ? 'https://token-plan-cn.xiaomimimo.com' : 'https://api.xiaomimimo.com';++/** What MiMo says when a key cannot work where it was sent, or the plan has nothing left. */+function guided(/** @type {unknown} */ e, /** @type {string} */ key) {+ const said = String(/** @type {Error} */ (e)?.message ?? e);+ /* a Token Plan key answered 401: it went where it was told (an OPENFILM_MIMO_URL), not where it belongs */+ if (/\(401\)/.test(said) && key.startsWith('tp-')) {+ return new Error(`${said} A Token Plan key answers at https://token-plan-cn.xiaomimimo.com; check OPENFILM_MIMO_URL is not pointing it elsewhere.`);+ }+ /* the plan's quota used up answers 429 */+ if (/answered 429/.test(said)) return noBalance(NAME);+ return e;+}++/**+ * The speech cut at its pauses: each stretch with its own bytes and where it starts in the file's seconds. Without a+ * pause to cut at there is one stretch, the whole of it. ffmpeg's own reading of the file decides how long it is.+ * @param {Uint8Array} bytes @param {AbortSignal} signal+ * @returns {Promise<{ stretches: { at: number, bytes: Uint8Array }[], total: number | null }>}+ */+async function stretches(bytes, signal) {+ const dir = await mkdtemp(join(tmpdir(), 'openfilm-mimo-'));+ const speech = join(dir, 'speech.mp3');+ await writeFile(speech, bytes);+ try {+ const stderr = await new Promise((done, fail) => execFile('ffmpeg',+ ['-nostdin', '-i', speech, '-af', `silencedetect=noise=${CUT_NOISE}:d=${CUT_SECONDS}`, '-f', 'null', '-'],+ { signal, encoding: 'utf8', windowsHide: true }, (error, _out, err) => error ? fail(error) : done(err)));+ const head = /Duration: (\d+):(\d+):(\d+\.\d+)/.exec(String(stderr));+ const total = head ? Number(head[1]) * 3600 + Number(head[2]) * 60 + Number(head[3]) : 0;+ const starts = [...String(stderr).matchAll(/silence_start: ([\d.]+)/g)].map((m) => Number(m[1]));+ const ends = [...String(stderr).matchAll(/silence_end: ([\d.]+)/g)].map((m) => Number(m[1]));+ /** @type {[number, number][]} */+ const silences = [];+ for (const [i, a] of starts.entries()) {+ const b = ends[i];+ if (!Number.isFinite(a) || !Number.isFinite(b)) continue;+ const last = silences.at(-1);+ /* a run of flutters is one pause */+ if (last && a - last[1] < 0.3) last[1] = b; else silences.push([a, b]);+ }+ const cuts = [0, ...silences.map(([a, b]) => (a + b) / 2), total || Infinity];+ /** @type {[number, number][]} */+ const spans = [];+ for (const [i, from] of cuts.slice(0, -1).entries()) {+ const to = cuts[i + 1];+ if (!(to > from)) continue;+ if (to - from < MIN_STRETCH) {+ const last = spans.at(-1);+ if (last) last[1] = to;+ else if (to - from > 0.05) spans.push([from, to]);+ continue;+ }+ spans.push([from, to]);+ }+ /** @type {{ at: number, bytes: Uint8Array }[]} */+ const out = [];+ let index = 0;+ for (const [from, to] of spans) {+ for (let at = from; at < to; at += MAX_STRETCH, index += 1) {+ const end = Math.min(at + MAX_STRETCH, to);+ const file = join(dir, `stretch-${index}.mp3`);+ await new Promise((done, fail) => execFile('ffmpeg',+ ['-nostdin', '-y', '-ss', at.toFixed(3), '-to', end.toFixed(3), '-i', speech, '-ac', '1', '-ar', '16000', '-c:a', 'libmp3lame', '-b:a', '32k', file],+ { signal, windowsHide: true }, (error) => error ? fail(error) : done(undefined)));+ out.push({ at, bytes: await readFile(file) });+ }+ }+ return { stretches: out, total: total || null };+ } finally {+ await rm(dir, { recursive: true, force: true }).catch(() => {});+ }+}++/** Stretch texts joined as they are written: a space between words, none next to CJK. */+const CJK = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;+/** @param {string[]} parts */+function joined(parts) {+ let out = '';+ for (const part of parts.filter(Boolean)) out += out && !CJK.test(out.slice(-1)) && !CJK.test(part.slice(0, 1)) ? ` ${part}` : part;+ return out;+}++/** @type {Provider} */+export default {+ id: 'mimo',+ name: NAME,+ env: 'MIMO_API_KEY',+ keysUrl: 'https://platform.xiaomimimo.com/console/api-keys',+ billingUrl: 'https://platform.xiaomimimo.com/console/recharge',+ verbs: ['voice', 'tts', 'asr'],+ models: MODELS,+ speechFormat: 'mp3',+ async run(verb, args, ctx) {+ const base = serviceUrl('MIMO', baseFor(ctx.key));+ const send = (/** @type {Record<string, unknown>} */ payload) =>+ call(NAME, `${base}/v1/chat/completions`, {+ method: 'POST', signal: AbortSignal.any([ctx.signal, AbortSignal.timeout(TIMEOUT_MS)]),+ headers: { 'content-type': 'application/json', 'api-key': ctx.key }, body: JSON.stringify(payload),+ }, ctx).catch((e) => { throw guided(e, ctx.key); });+ /** @returns {Promise<any>} */+ const answered = async (/** @type {Record<string, unknown>} */ payload) => {+ const res = await send(payload);+ try { return await res.json(); } catch { throw new Error(`${NAME} answered without JSON. Not retried.`); }+ };++ if (verb === 'voice') {+ const said = [+ ...(text(args.language) ? ['MiMo\'s voices speak what they are given: --language does not narrow them'] : []),+ ...(text(args.gender) ? ['MiMo\'s voices have no set gender'] : []),+ ...(text(args.prompt) ? ['--prompt does not narrow MiMo\'s voices'] : []),+ ];+ const limit = clamp(Math.round(number(args.limit) ?? 5), 1, 100);+ const voices = VOICES.slice(0, limit).map((id) => ({ voiceId: id, name: id === 'mimo_default' ? 'Default' : id, language: null, gender: null, description: null }));+ return { files: [], index: [], receipt: { provider: 'mimo', voices, ...notes(said) } };+ }+ if (verb === 'tts') {+ const said = needed(args, 'text');+ const voice = needed(args, 'voice');+ const model = modelOf(MODELS, 'tts', ctx);+ const body = await answered({+ model,+ messages: [{ role: 'assistant', content: said }],+ audio: { format: 'wav', voice },+ });+ const data = body?.choices?.[0]?.message?.audio?.data;+ if (typeof data !== 'string' || !data) throw new Error(`${NAME} answered with no audio. Not retried.`);+ const bytes = new Uint8Array(Buffer.from(data, 'base64'));+ const dur = wavSeconds(bytes);+ const path = landing('audio/vo', args.out, 'wav');+ return {+ files: [{ path, bytes }],+ index: [{ src: path, kind: 'audio', ...(dur !== null ? { dur } : {}), text: said, voice, from: { mode: 'synth', text: said, provider: 'mimo', model } }],+ receipt: { provider: 'mimo', model, src: path, dur, voice, notes: ['MiMo gives no word timings: `get asr` on the file makes timed subtitles'] },+ cost: billedBy(NAME),+ };+ }+ if (verb === 'asr') {+ const src = needed(args, 'src');+ const bytes = await ctx.read(src);+ if (!bytes.length || bytes.length >= MAX_UPLOAD) throw new Error(`MiMo takes speech under 100 MB and this is ${Math.ceil(bytes.length / 1048576)} MB. No audio was uploaded.`);+ const model = modelOf(MODELS, 'asr', ctx);+ /* the speech cut at its pauses, each stretch asked for on its own: when it was said is real, within a+ stretch is spread by characters, as there is nothing finer to go by */+ const cut = await stretches(bytes, ctx.signal).catch(() => ({ stretches: [{ at: 0, bytes }], total: null }));+ /** @type {{ at: number, line: string, seconds: number | null }[]} */+ const heard = [];+ for (const stretch of cut.stretches) {+ const body = await answered({+ model,+ messages: [{ role: 'user', content: [{ type: 'input_audio', input_audio: { data: `data:audio/mpeg;base64,${Buffer.from(stretch.bytes).toString('base64')}` } }] }],+ });+ const line = text(body?.choices?.[0]?.message?.content);+ const seconds = Number(body?.usage?.seconds);+ heard.push({ at: stretch.at, line, seconds: Number.isFinite(seconds) && seconds > 0 ? seconds : null });+ }+ /* the file's own length, or the stretches' own counted seconds when ffmpeg could not read it */+ const total = cut.total ?? (heard.reduce((end, h) => Math.max(end, h.at + (h.seconds ?? 0)), 0) || null);+ /** @type {{ token: string, start: number, end: number }[]} */+ const words = [];+ const said = [];+ for (const [i, h] of heard.entries()) {+ if (!h.line) continue;+ said.push(h.line);+ const until = heard[i + 1]?.at ?? total ?? h.at + (h.seconds ?? MAX_STRETCH);+ const characters = [...h.line];+ const step = Math.max(0.1, until - h.at) / characters.length;+ words.push(...wordsFromCharacters(characters,+ characters.map((_, k) => h.at + k * step), characters.map((_, k) => h.at + (k + 1) * step), total ?? undefined)+ .map((w) => ({ ...w, start: round(w.start), end: round(w.end) })));+ }+ const full = joined(said);+ return {+ files: [],+ index: [{ src, text: full, ...(total ? { dur: round(total) } : {}), ...(words.length ? { words } : {}), transcribed: true }],+ receipt: { provider: 'mimo', model, src, text: full, notes: ['Word times are the pauses MiMo\'s speech was cut at, spread within each stretch'] },+ cost: billedBy(NAME),+ };+ }+ throw new Error(`${NAME} does not do ${verb}.`);+ },+};diff --git a/packages/openfilm/studio/server/providers/mimo.test.mjs b/packages/openfilm/studio/server/providers/mimo.test.mjsnew file mode 100644index 0000000..b750005--- /dev/null+++ b/packages/openfilm/studio/server/providers/mimo.test.mjs@@ -0,0 +1,172 @@+import { test, before, after, beforeEach } from 'node:test';+import assert from 'node:assert/strict';+import { execFileSync } from 'node:child_process';+import { createServer } from 'node:http';+import { mkdtempSync, readFileSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import mimo, { baseFor } from './mimo.mjs';+import { wav } from './common.mjs';++const KEY = 'sk-test_0123456789abcdef';+/** a fake Xiaomi MiMo on 127.0.0.1: `reply` answers each request; `seen` keeps them. */+let server;+let reply = () => [404, {}];+const seen = [];++before(async () => {+ server = createServer(async (req, res) => {+ const chunks = [];+ for await (const c of req) chunks.push(c);+ const call = { method: req.method, url: new URL(req.url, 'http://x'), headers: req.headers, body: Buffer.concat(chunks) };+ seen.push(call);+ const [status, body] = await reply(call);+ res.writeHead(status, { 'content-type': 'application/json' }).end(JSON.stringify(body));+ });+ await new Promise((done) => server.listen(0, '127.0.0.1', done));+ process.env.OPENFILM_MIMO_URL = `http://127.0.0.1:${server.address().port}`;+});+after(() => server.close());+beforeEach(() => { seen.length = 0; });++const ctx = (files = {}, model, key = KEY) => ({ key, model, root: '/project', signal: new AbortController().signal, say: () => {}, read: async (p) => files[p] });+const sent = (call) => JSON.parse(call.body.toString('utf8'));+const asked = (call) => sent(call).messages[0].content[0].input_audio.data;++/** Speech ffmpeg can cut: `sine` with a real pause of `gap` seconds between two stretches. */+function speechWithAPause(gap) {+ const dir = mkdtempSync(join(tmpdir(), 'mimo-cut-'));+ const file = join(dir, 'talk.wav');+ execFileSync('ffmpeg', ['-v', 'error', '-y',+ '-f', 'lavfi', '-i', 'sine=frequency=440:duration=0.8',+ '-f', 'lavfi', `-i`, `anullsrc=r=16000:cl=mono:d=${gap}`,+ '-f', 'lavfi', '-i', 'sine=frequency=440:duration=0.8',+ '-filter_complex', '[0:a][1:a][2:a]concat=n=3:v=0:a=1', '-ac', '1', '-ar', '16000', file]);+ return new Uint8Array(readFileSync(file));+}++test('transcription: MiMo-V2.5-ASR with the audio inline in a chat completion, the key as api-key', async () => {+ reply = () => [200, { choices: [{ finish_reason: 'stop', message: { content: 'Hello,大家好。' } }], usage: { seconds: 4 } }];+ const mp3 = new Uint8Array(Buffer.concat([Buffer.from('ID3'), Buffer.alloc(100)]));+ const result = await mimo.run('asr', { src: 'assets/upload/talk.mp4' }, ctx({ 'assets/upload/talk.mp4': mp3 }));+ const call = seen.at(-1);+ const body = sent(call);+ assert.equal(call.url.pathname, '/v1/chat/completions');+ assert.equal(call.headers['api-key'], KEY);+ assert.equal(body.model, 'mimo-v2.5-asr');+ assert.equal(body.messages[0].content[0].type, 'input_audio');+ assert.match(asked(call), /^data:audio\/mpeg;base64,/);+ /* nothing to cut at (the bytes are not audio ffmpeg can read): one stretch, its words over the counted seconds */+ assert.equal(seen.filter((c) => c.url.pathname === '/v1/chat/completions').length, 1);+ assert.deepEqual(result.files, [], 'the provider writes no files: runGet lands the transcript');+ assert.deepEqual(result.index, [{ src: 'assets/upload/talk.mp4', text: 'Hello,大家好。', dur: 4, transcribed: true, words: [+ { token: 'Hello,', start: 0, end: 2.4 }, { token: '大', start: 2.4, end: 2.8 }, { token: '家', start: 2.8, end: 3.2 }, { token: '好。', start: 3.2, end: 4 }] }]);+ assert.equal(result.receipt.provider, 'mimo');+ assert.equal(result.receipt.model, 'mimo-v2.5-asr');+ assert.equal(result.receipt.text, 'Hello,大家好。');+ assert.match(result.receipt.notes[0], /pauses/);+ assert.match(result.cost.note, /billed by Xiaomi MiMo/);+});++test('speech cut at its pauses: each stretch asked for on its own, its words in the time it was said', async () => {+ reply = () => (seen.filter((c) => c.url.pathname === '/v1/chat/completions').length === 1+ ? [200, { choices: [{ message: { content: '第一段。' } }], usage: { seconds: 1 } }]+ : [200, { choices: [{ message: { content: 'Second stretch.' } }], usage: { seconds: 1 } }]);+ const file = speechWithAPause(0.8);+ const result = await mimo.run('asr', { src: 'assets/talk.wav' }, ctx({ 'assets/talk.wav': file }));+ const mine = seen.filter((c) => c.url.pathname === '/v1/chat/completions');+ assert.equal(mine.length, 2, 'two stretches, one request each');+ assert.match(asked(mine[0]), /^data:audio\/mpeg;base64,/);+ assert.notEqual(asked(mine[0]), asked(mine[1]), 'each stretch its own audio');+ /* 0.8 s speech, 0.8 s pause, 0.8 s speech: the cut is the pause's middle, at 1.2 s */+ assert.equal(result.index[0].dur, 2.4);+ assert.equal(result.index[0].text, '第一段。 Second stretch.');+ const words = result.index[0].words;+ assert.deepEqual(words.map((w) => w.token), ['第', '一', '段。', 'Second', 'stretch.']);+ assert.equal(words[0].start, 0);+ assert.ok(words[2].end <= 1.21 && words[2].end >= 1.19, `the first stretch's last word ends at the pause (${words[2].end})`);+ assert.ok(words[3].start >= 1.19 && words[3].start <= 1.21, `the second stretch starts at the pause (${words[3].start})`);+ assert.ok(words.at(-1).end <= 2.41, 'words never past the file');+});++test('the model chosen in Settings is the one asked for', async () => {+ reply = () => [200, { choices: [{ message: { content: 'Two.' } }], usage: { seconds: 1 } }];+ const mp3 = new Uint8Array(Buffer.concat([Buffer.from('ID3'), Buffer.alloc(10)]));+ await mimo.run('asr', { src: 'assets/talk.mp3' }, ctx({ 'assets/talk.mp3': mp3 }, 'mimo-v2.5-asr'));+ assert.equal(sent(seen.at(-1)).model, 'mimo-v2.5-asr');+});++test('speech over 100 MB is refused before anything is sent', async () => {+ const before = seen.length;+ const huge = new Uint8Array(100 * 1024 * 1024);+ await assert.rejects(mimo.run('asr', { src: 'assets/big.mp3' }, ctx({ 'assets/big.mp3': huge })), /under 100 MB.*No audio was uploaded/);+ assert.equal(seen.length, before);+});++test('the key says where it answers: a Token Plan key at its gateway, a platform key at the pay-as-you-go API', () => {+ assert.equal(baseFor('tp-test_0123456789abcdef'), 'https://token-plan-cn.xiaomimimo.com');+ assert.equal(baseFor('sk-test_0123456789abcdef'), 'https://api.xiaomimimo.com');+});++test('a Token Plan key pointed elsewhere is told where it belongs; a used-up plan is a balance', async () => {+ const mp3 = new Uint8Array(Buffer.concat([Buffer.from('ID3'), Buffer.alloc(10)]));+ const files = { 'assets/talk.mp3': mp3 };+ reply = () => [401, { error: { message: 'Invalid API Key' } }];+ await assert.rejects(mimo.run('asr', { src: 'assets/talk.mp3' }, ctx(files, undefined, 'tp-test_0123456789abcdef')),+ /Token Plan key answers at https:\/\/token-plan-cn\.xiaomimimo\.com; check OPENFILM_MIMO_URL/);+ reply = () => [429, { error: { message: 'quota exhausted' } }];+ await assert.rejects(mimo.run('asr', { src: 'assets/talk.mp3' }, ctx(files)), (e) => e.code === 'balance');+ reply = () => [401, { error: { message: 'Invalid API Key' } }];+ await assert.rejects(mimo.run('asr', { src: 'assets/talk.mp3' }, ctx(files)), /did not accept your key.*Settings/, 'a platform key that is simply wrong says only that');+});++test('a key it does not accept, an emptied account and an untranscribable answer each say so plainly', async () => {+ const mp3 = new Uint8Array(Buffer.concat([Buffer.from('ID3'), Buffer.alloc(10)]));+ const files = { 'assets/talk.mp3': mp3 };+ reply = () => [402, { error: { message: 'Insufficient account balance' } }];+ await assert.rejects(mimo.run('asr', { src: 'assets/talk.mp3' }, ctx(files)), (e) => e.code === 'balance');+ reply = () => [200, { choices: [{ message: { content: null } }] }];+ const silent = await mimo.run('asr', { src: 'assets/talk.mp3' }, ctx(files));+ assert.equal(silent.index[0].text, '', 'silence is an answer, not an error');+ assert.equal(silent.index[0].dur, undefined);+});++test('voices: the nine the API names, a limit honored; filters are said not to narrow them', async () => {+ const all = await mimo.run('voice', { limit: 100 }, ctx());+ assert.deepEqual(all.receipt.voices.map((v) => v.voiceId), ['mimo_default', '冰糖', '茉莉', '苏打', '白桦', 'Mia', 'Chloe', 'Milo', 'Dean']);+ assert.equal(all.receipt.voices[0].name, 'Default');+ assert.equal(all.receipt.voices[2].name, '茉莉');+ assert.equal(all.receipt.notes, undefined, 'asked for nothing: nothing said');+ const few = await mimo.run('voice', { limit: 2, language: 'en', gender: 'f', prompt: 'whispery' }, ctx());+ assert.deepEqual(few.receipt.voices.map((v) => v.voiceId), ['mimo_default', '冰糖']);+ assert.equal(few.receipt.notes.length, 3);+});++test('voice-over: MiMo-V2.5-TTS as a WAV in the answer, the line as the assistant\'s message', async () => {+ reply = () => [200, { choices: [{ message: { content: '', audio: { data: Buffer.from(wav(new Uint8Array(48000), 24000)).toString('base64') } } }] }];+ const result = await mimo.run('tts', { out: 'line', text: 'Hello there.', voice: 'Chloe' }, ctx());+ const body = sent(seen.at(-1));+ assert.equal(seen.at(-1).url.pathname, '/v1/chat/completions');+ assert.equal(seen.at(-1).headers['api-key'], KEY);+ assert.equal(body.model, 'mimo-v2.5-tts');+ assert.deepEqual(body.messages, [{ role: 'assistant', content: 'Hello there.' }]);+ assert.deepEqual(body.audio, { format: 'wav', voice: 'Chloe' });+ assert.equal(result.files[0].path, 'assets/audio/vo/line.wav');+ assert.equal(result.files[0].bytes.length, 48044, 'the WAV as it came, header and all');+ assert.deepEqual(result.index, [{ src: 'assets/audio/vo/line.wav', kind: 'audio', dur: 1, text: 'Hello there.', voice: 'Chloe',+ from: { mode: 'synth', text: 'Hello there.', provider: 'mimo', model: 'mimo-v2.5-tts' } }]);+ assert.equal(result.receipt.voice, 'Chloe');+ assert.match(result.receipt.notes[0], /no word timings/);+});++test('a voice it does not know is said so in the answer; an answer with no audio is refused', async () => {+ const files = {};+ reply = () => [400, { error: { code: '400', message: 'Param Incorrect', param: 'Unknown voice: NoSuchVoice. Available voices: [mimo_default, Chloe]' } }];+ await assert.rejects(mimo.run('tts', { out: 'x', text: 'hi', voice: 'NoSuchVoice' }, ctx(files)), /Xiaomi MiMo answered 400: Param Incorrect/);+ reply = () => [200, { choices: [{ message: { content: '' } }] }];+ await assert.rejects(mimo.run('tts', { out: 'x', text: 'hi', voice: 'Chloe' }, ctx(files)), /answered with no audio/);+});++test('another verb is refused', async () => {+ await assert.rejects(mimo.run('sfx', { out: 'x', prompt: 'boom' }, ctx()), /Xiaomi MiMo does not do sfx/);+});diff --git a/packages/openfilm/studio/ui/src/lib/provider-marks.ts b/packages/openfilm/studio/ui/src/lib/provider-marks.tsindex 0498bdf..40249c4 100644--- a/packages/openfilm/studio/ui/src/lib/provider-marks.ts+++ b/packages/openfilm/studio/ui/src/lib/provider-marks.ts@@ -1,7 +1,7 @@/*** Each provider's mark, one color (the text's), as Settings → Providers lists them (and Settings → Agents its agents).* The marks are from Lobe Icons (https://github.com/lobehub/lobe-icons, MIT); Claude's, Cursor's, Copilot's, OpenCode's,- * MiniMax's, Brave's, Pexels', Pixabay's and Google's from Simple Icons (CC0). A mark drawn in shades of its one color has `parts`, each with+ * MiniMax's, Brave's, Pexels', Pixabay's, Google's and Xiaomi's from Simple Icons (CC0). A mark drawn in shades of its one color has `parts`, each with* its opacity. A service with no mark here (a new one, until it has one) is a letter cut out of a rounded square.*/@@ -19,6 +19,7 @@ export const MARKS: Record<string, { viewBox: string; d: string; parts?: { d: stkimi: { viewBox: '0 0 24 24', d: 'M21.846 0a1.923 1.923 0 110 3.846H20.15a.226.226 0 01-.227-.226V1.923C19.923.861 20.784 0 21.846 0zM11.065 11.199l7.257-7.2c.137-.136.06-.41-.116-.41H14.3a.164.164 0 00-.117.051l-7.82 7.756c-.122.12-.302.013-.302-.179V3.82c0-.127-.083-.23-.185-.23H3.186c-.103 0-.186.103-.186.23V19.77c0 .128.083.23.186.23h2.69c.103 0 .186-.102.186-.23v-3.25c0-.069.025-.135.069-.178l2.424-2.406a.158.158 0 01.205-.023l6.484 4.772a7.677 7.677 0 003.453 1.283c.108.012.2-.095.2-.23v-3.06c0-.117-.07-.212-.164-.227a5.028 5.028 0 01-2.027-.807l-5.613-4.064c-.117-.078-.132-.279-.028-.381z' },deepseek: { viewBox: '0 0 24 24', d: 'M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z' },minimax: { viewBox: '0 0 24 24', d: 'M11.43 3.92a.86.86 0 1 0-1.718 0v14.236a1.999 1.999 0 0 1-3.997 0V9.022a.86.86 0 1 0-1.718 0v3.87a1.999 1.999 0 0 1-3.997 0V11.49a.57.57 0 0 1 1.139 0v1.404a.86.86 0 0 0 1.719 0V9.022a1.999 1.999 0 0 1 3.997 0v9.134a.86.86 0 0 0 1.719 0V3.92a1.998 1.998 0 1 1 3.996 0v11.788a.57.57 0 1 1-1.139 0zm10.572 3.105a2 2 0 0 0-1.999 1.997v7.63a.86.86 0 0 1-1.718 0V3.923a1.999 1.999 0 0 0-3.997 0v16.16a.86.86 0 0 1-1.719 0V18.08a.57.57 0 1 0-1.138 0v2a1.998 1.998 0 0 0 3.996 0V3.92a.86.86 0 0 1 1.719 0v12.73a1.999 1.999 0 0 0 3.996 0V9.023a.86.86 0 1 1 1.72 0v6.686a.57.57 0 0 0 1.138 0V9.022a2 2 0 0 0-1.998-1.997' },+ mimo: { viewBox: '0 0 24 24', d: 'M12 0C8.016 0 4.756.255 2.493 2.516.23 4.776 0 8.033 0 12.012c0 3.98.23 7.235 2.494 9.497C4.757 23.77 8.017 24 12 24c3.983 0 7.243-.23 9.506-2.491C23.77 19.247 24 15.99 24 12.012c0-3.984-.233-7.243-2.502-9.504C19.234.252 15.978 0 12 0zM4.906 7.405h5.624c1.47 0 3.007.068 3.764.827.746.746.827 2.233.83 3.676v4.54a.15.15 0 0 1-.152.147h-1.947a.15.15 0 0 1-.152-.148V11.83c-.002-.806-.048-1.634-.464-2.051-.358-.36-1.026-.441-1.72-.458H7.158a.15.15 0 0 0-.151.147v6.98a.15.15 0 0 1-.152.148H4.906a.15.15 0 0 1-.15-.148V7.554a.15.15 0 0 1 .15-.149zm12.131 0h1.949a.15.15 0 0 1 .15.15v8.892a.15.15 0 0 1-.15.148h-1.949a.15.15 0 0 1-.151-.148V7.554a.15.15 0 0 1 .151-.149zM8.92 10.948h2.046c.083 0 .15.066.15.147v5.352a.15.15 0 0 1-.15.148H8.92a.15.15 0 0 1-.152-.148v-5.352a.15.15 0 0 1 .152-.147Z' },fal: { viewBox: '0 0 24 24', d: 'M15.477 0c.415 0 .749.338.788.752a7.775 7.775 0 006.985 6.984c.413.04.752.373.752.788v6.952c0 .415-.338.748-.752.788a7.775 7.775 0 00-6.985 6.984c-.04.414-.373.752-.788.752H8.525c-.416 0-.749-.338-.789-.752a7.775 7.775 0 00-6.984-6.984c-.414-.04-.752-.373-.752-.788V8.524c0-.415.338-.748.752-.788A7.775 7.775 0 007.736.752C7.776.338 8.11 0 8.526 0h6.95zM4.819 11.98a7.226 7.226 0 007.223 7.23 7.226 7.226 0 007.223-7.23c0-3.994-3.234-7.23-7.223-7.23a7.227 7.227 0 00-7.223 7.23z' },brave: { viewBox: '0 0 24 24', d: 'M15.68 0l2.096 2.38s1.84-.512 2.709.358c.868.87 1.584 1.638 1.584 1.638l-.562 1.381.715 2.047s-2.104 7.98-2.35 8.955c-.486 1.919-.818 2.66-2.198 3.633-1.38.972-3.884 2.66-4.293 2.916-.409.256-.92.692-1.38.692-.46 0-.97-.436-1.38-.692a185.796 185.796 0 01-4.293-2.916c-1.38-.973-1.712-1.714-2.197-3.633-.247-.975-2.351-8.955-2.351-8.955l.715-2.047-.562-1.381s.716-.768 1.585-1.638c.868-.87 2.708-.358 2.708-.358L8.321 0h7.36zm-3.679 14.936c-.14 0-1.038.317-1.758.69-.72.373-1.242.637-1.409.742-.167.104-.065.301.087.409.152.107 2.194 1.69 2.393 1.866.198.175.489.464.687.464.198 0 .49-.29.688-.464.198-.175 2.24-1.759 2.392-1.866.152-.108.254-.305.087-.41-.167-.104-.689-.368-1.41-.741-.72-.373-1.617-.69-1.757-.69zm0-11.278s-.409.001-1.022.206-1.278.46-1.584.46c-.307 0-2.581-.434-2.581-.434S4.119 7.152 4.119 7.849c0 .697.339.881.68 1.243l2.02 2.149c.192.203.59.511.356 1.066-.235.555-.58 1.26-.196 1.977.384.716 1.042 1.194 1.464 1.115.421-.08 1.412-.598 1.776-.834.364-.237 1.518-1.19 1.518-1.554 0-.365-1.193-1.02-1.413-1.168-.22-.15-1.226-.725-1.247-.95-.02-.227-.012-.293.284-.851.297-.559.831-1.304.742-1.8-.089-.495-.95-.753-1.565-.986-.615-.232-1.799-.671-1.947-.74-.148-.068-.11-.133.339-.175.448-.043 1.719-.212 2.292-.052.573.16 1.552.403 1.632.532.079.13.149.134.067.579-.081.445-.5 2.581-.541 2.96-.04.38-.12.63.288.724.409.094 1.097.256 1.333.256s.924-.162 1.333-.256c.408-.093.329-.344.288-.723-.04-.38-.46-2.516-.541-2.961-.082-.445-.012-.45.067-.579.08-.129 1.059-.372 1.632-.532.573-.16 1.845.009 2.292.052.449.042.487.107.339.175-.148.069-1.332.508-1.947.74-.615.233-1.476.49-1.565.986-.09.496.445 1.241.742 1.8.297.558.304.624.284.85-.02.226-1.026.802-1.247.95-.22.15-1.413.804-1.413 1.169 0 .364 1.154 1.317 1.518 1.554.364.236 1.355.755 1.776.834.422.079 1.08-.4 1.464-1.115.384-.716.039-1.422-.195-1.977-.235-.555.163-.863.355-1.066l2.02-2.149c.341-.362.68-.546.68-1.243 0-.697-2.695-3.96-2.695-3.96s-2.274.436-2.58.436c-.307 0-.972-.256-1.585-.461-.613-.205-1.022-.206-1.022-.206z' },pexels: { viewBox: '0 0 24 24', d: 'M1.5 0A1.5 1.5 0 000 1.5v21A1.5 1.5 0 001.5 24h21a1.5 1.5 0 001.5-1.5v-21A1.5 1.5 0 0022.5 0h-21zm6.75 6.75h5.2715a3.843 3.843 0 01.627 7.6348V17.25H8.25V6.75zm1.5 1.5v7.5h2.8984v-2.8145h.873a2.343 2.343 0 100-4.6855H9.75Z' },