Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linter errors #23

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@ import first from 'lodash/first'
import last from 'lodash/last'
import omit from 'lodash/omit'
import maxBy from 'lodash/maxBy'
import isEmpty from 'lodash/isEmpty'
import orderBy from 'lodash/orderBy'
import uniqueId from 'lodash/uniqueId'
import takeRight from 'lodash/takeRight'
import assign from 'lodash/assign'
import { exec } from 'child_process'
import fs from 'fs'
import appRoot from 'app-root-path'
import os from 'os'

Expand All @@ -60,7 +57,9 @@ const parseOutput = body => {
const split = new RegExp("^(.*):\\s*(.*)$", "mg")
let match = ''
let dict = {} //simple key:value
while(match = split.exec(body)) dict[match[1]] = parseFloat(match[2])
while((match = split.exec(body)) !== null) {
dict[match[1]] = parseFloat(match[2])
}
return dict
}

Expand Down Expand Up @@ -126,7 +125,7 @@ class ClapDetector {

listen() {
try {
const { MAX_HISTORY_LENGTH, AUDIO_SOURCE, DETECTION_PERCENTAGE_START, DETECTION_PERCENTAGE_END } = this.config
const { AUDIO_SOURCE, DETECTION_PERCENTAGE_START, DETECTION_PERCENTAGE_END } = this.config
const filename = appRoot + '/input.wav'
// Listen for sound
const cmd = 'sox -t ' + AUDIO_SOURCE + ' ' + filename + ' silence 1 0.0001 ' + DETECTION_PERCENTAGE_START + ' 1 0.1 ' + DETECTION_PERCENTAGE_END + ' −−no−show−progress stat'
Expand All @@ -135,7 +134,6 @@ class ClapDetector {
this.child = exec(cmd, (err) => {
if (err) {
throw err
return
}
})

Expand Down