mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-05 18:09:23 +08:00
Audio in only (#15)
* Audio + Video / test Audio * Add code * Fix demo * support additional inputs * Add code * Add code
This commit is contained in:
@@ -3,13 +3,12 @@
|
||||
|
||||
export let numBars = 16;
|
||||
export let stream_state: "open" | "closed" | "waiting" = "closed";
|
||||
export let audio_source: HTMLAudioElement;
|
||||
export let audio_source_callback: () => MediaStream;
|
||||
|
||||
let audioContext: AudioContext;
|
||||
let analyser: AnalyserNode;
|
||||
let dataArray: Uint8Array;
|
||||
let animationId: number;
|
||||
let is_muted = false;
|
||||
|
||||
$: containerWidth = `calc((var(--boxSize) + var(--gutter)) * ${numBars})`;
|
||||
|
||||
@@ -27,7 +26,7 @@
|
||||
function setupAudioContext() {
|
||||
audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||
analyser = audioContext.createAnalyser();
|
||||
const source = audioContext.createMediaStreamSource(audio_source.srcObject);
|
||||
const source = audioContext.createMediaStreamSource(audio_source_callback());
|
||||
|
||||
// Only connect to analyser, not to destination
|
||||
source.connect(analyser);
|
||||
|
||||
Reference in New Issue
Block a user