ngxson HF Staff commited on
Commit
50025c3
·
1 Parent(s): c3f0f02
Files changed (2) hide show
  1. front/src/components/AudioPlayer.tsx +1 -2
  2. index.html +14 -34
front/src/components/AudioPlayer.tsx CHANGED
@@ -1,6 +1,5 @@
1
  import React, { useMemo, useEffect } from 'react';
2
- import { audioBufferToWav, blobFromAudioBuffer } from '../utils/utils';
3
- import { encode } from 'base64-arraybuffer';
4
 
5
  interface AudioPlayerProps {
6
  audioBuffer: AudioBuffer;
 
1
  import React, { useMemo, useEffect } from 'react';
2
+ import { blobFromAudioBuffer } from '../utils/utils';
 
3
 
4
  interface AudioPlayerProps {
5
  audioBuffer: AudioBuffer;
index.html CHANGED
@@ -13307,23 +13307,23 @@ class TextLineStream extends TransformStream {
13307
  /** Constructs a new instance. */
13308
  constructor(options = { allowCR: false }) {
13309
  super({
13310
- transform: (chars2, controller) => {
13311
- chars2 = __privateGet2(this, _currentLine) + chars2;
13312
  while (true) {
13313
- const lfIndex = chars2.indexOf("\n");
13314
- const crIndex = options.allowCR ? chars2.indexOf("\r") : -1;
13315
- if (crIndex !== -1 && crIndex !== chars2.length - 1 && (lfIndex === -1 || lfIndex - 1 > crIndex)) {
13316
- controller.enqueue(chars2.slice(0, crIndex));
13317
- chars2 = chars2.slice(crIndex + 1);
13318
  continue;
13319
  }
13320
  if (lfIndex === -1)
13321
  break;
13322
- const endIndex = chars2[lfIndex - 1] === "\r" ? lfIndex - 1 : lfIndex;
13323
- controller.enqueue(chars2.slice(0, endIndex));
13324
- chars2 = chars2.slice(lfIndex + 1);
13325
  }
13326
- __privateSet2(this, _currentLine, chars2);
13327
  },
13328
  flush: (controller) => {
13329
  if (__privateGet2(this, _currentLine) === "")
@@ -14884,39 +14884,19 @@ const blobFromAudioBuffer = (audioBuffer) => {
14884
  const wavArrayBuffer = audioBufferToWav(audioBuffer, { float32: false });
14885
  return new Blob([wavArrayBuffer], { type: "audio/wav" });
14886
  };
14887
- var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
14888
- var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
14889
- for (var i = 0; i < chars.length; i++) {
14890
- lookup[chars.charCodeAt(i)] = i;
14891
- }
14892
- var encode = function(arraybuffer) {
14893
- var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = "";
14894
- for (i = 0; i < len; i += 3) {
14895
- base64 += chars[bytes[i] >> 2];
14896
- base64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
14897
- base64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
14898
- base64 += chars[bytes[i + 2] & 63];
14899
- }
14900
- if (len % 3 === 2) {
14901
- base64 = base64.substring(0, base64.length - 1) + "=";
14902
- } else if (len % 3 === 1) {
14903
- base64 = base64.substring(0, base64.length - 2) + "==";
14904
- }
14905
- return base64;
14906
- };
14907
  const AudioPlayer = ({ audioBuffer }) => {
14908
  const blobUrl = reactExports.useMemo(() => {
14909
  const wavBlob = blobFromAudioBuffer(audioBuffer);
14910
  return URL.createObjectURL(wavBlob);
14911
  }, [audioBuffer]);
14912
  const downloadUrl = reactExports.useMemo(() => {
14913
- const wavArrayBuffer = audioBufferToWav(audioBuffer, { float32: false });
14914
- const base64 = encode(wavArrayBuffer);
14915
- return `data:audio/wav;base64,${base64}`;
14916
  }, [audioBuffer]);
14917
  reactExports.useEffect(() => {
14918
  return () => {
14919
  URL.revokeObjectURL(blobUrl);
 
14920
  };
14921
  }, [blobUrl]);
14922
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 flex items-center", children: [
 
13307
  /** Constructs a new instance. */
13308
  constructor(options = { allowCR: false }) {
13309
  super({
13310
+ transform: (chars, controller) => {
13311
+ chars = __privateGet2(this, _currentLine) + chars;
13312
  while (true) {
13313
+ const lfIndex = chars.indexOf("\n");
13314
+ const crIndex = options.allowCR ? chars.indexOf("\r") : -1;
13315
+ if (crIndex !== -1 && crIndex !== chars.length - 1 && (lfIndex === -1 || lfIndex - 1 > crIndex)) {
13316
+ controller.enqueue(chars.slice(0, crIndex));
13317
+ chars = chars.slice(crIndex + 1);
13318
  continue;
13319
  }
13320
  if (lfIndex === -1)
13321
  break;
13322
+ const endIndex = chars[lfIndex - 1] === "\r" ? lfIndex - 1 : lfIndex;
13323
+ controller.enqueue(chars.slice(0, endIndex));
13324
+ chars = chars.slice(lfIndex + 1);
13325
  }
13326
+ __privateSet2(this, _currentLine, chars);
13327
  },
13328
  flush: (controller) => {
13329
  if (__privateGet2(this, _currentLine) === "")
 
14884
  const wavArrayBuffer = audioBufferToWav(audioBuffer, { float32: false });
14885
  return new Blob([wavArrayBuffer], { type: "audio/wav" });
14886
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14887
  const AudioPlayer = ({ audioBuffer }) => {
14888
  const blobUrl = reactExports.useMemo(() => {
14889
  const wavBlob = blobFromAudioBuffer(audioBuffer);
14890
  return URL.createObjectURL(wavBlob);
14891
  }, [audioBuffer]);
14892
  const downloadUrl = reactExports.useMemo(() => {
14893
+ const wavBlob = blobFromAudioBuffer(audioBuffer);
14894
+ return URL.createObjectURL(wavBlob);
 
14895
  }, [audioBuffer]);
14896
  reactExports.useEffect(() => {
14897
  return () => {
14898
  URL.revokeObjectURL(blobUrl);
14899
+ URL.revokeObjectURL(downloadUrl);
14900
  };
14901
  }, [blobUrl]);
14902
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 flex items-center", children: [