<commit_before>import {Recorderjs} from "../vendor/Recorder";

export class Mic {
	constructor(workerPath) {
		const nav = window.navigator;
		nav.getUserMedia = (
			nav.getUserMedia ||
			nav.webkitGetUserMedia ||
			nav.mozGetUserMedia ||
			nav.msGetUserMedia
		);
		this.navigator = nav;

		const AudioContext = window.AudioContext || window.webkitAudioContext;
		this.context = new AudioContext();

		this.navigator.getUserMedia({
			audio: true
		}, localMediaStream => {
			this.mediaStream = localMediaStream;

			var mediaStreamSource = this.context.createMediaStreamSource(localMediaStream);
			this.rec = new Recorderjs(mediaStreamSource, {
				workerPath: workerPath,
			});

		}, err => {
			console.log('Browser not supported');
		});
	}

	record() {
		this.rec.record();
	}

	pause() {
		this.rec.stop();
	}

	stop(cb) {
		this.pause();

		this.mediaStream.stop();
		this.rec.exportWAV(e => {
			this.rec.clear();
			cb(e);
			// Recorderjs.forceDownload(e, "filename.wav");
		});
	}
}<commit_msg>fix recorder deleting sound before upload verified<commit_after>import {Recorderjs} from "../vendor/Recorder";

export class Mic {
	constructor(workerPath) {
		const nav = window.navigator;
		nav.getUserMedia = (
			nav.getUserMedia ||
			nav.webkitGetUserMedia ||
			nav.mozGetUserMedia ||
			nav.msGetUserMedia
		);
		this.navigator = nav;

		const AudioContext = window.AudioContext || window.webkitAudioContext;
		this.context = new AudioContext();

		this.navigator.getUserMedia({
			audio: true
		}, localMediaStream => {
			this.mediaStream = localMediaStream;

			var mediaStreamSource = this.context.createMediaStreamSource(localMediaStream);
			this.rec = new Recorderjs(mediaStreamSource, {
				workerPath: workerPath,
			});

		}, err => {
			console.log('Browser not supported');
		});
	}

	record() {
		this.rec.record();
	}

	pause() {
		this.rec.stop();
	}

	stop(cb) {
		this.pause();

		this.mediaStream.stop();
		this.rec.exportWAV(e => {
			cb(e);
			//this.rec.clear();
			// Recorderjs.forceDownload(e, "filename.wav");
		});
	}
}
{'fraction_non_alphanumeric': 0.14721549636803874, 'fraction_numerical': 0.0, 'mean_word_length': 3.621923937360179, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6791177', 'n_tokens_mistral': 796, 'n_tokens_neox': 682, 'n_words': 116}