From: Alex Sadleir Date: Wed, 02 Jan 2013 00:05:15 +0000 Subject: select input X-Git-Url: https://maxious.lambdacomplex.org/git/?p=scannr.git&a=commitdiff&h=d45092073c216d17f214015064451a7ea949b2ba --- select input --- --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,6 @@ - @@ -16,7 +15,7 @@ - + @@ -38,14 +37,14 @@ - + - + - + + - - + - + - + @@ -487,7 +486,7 @@ - + --- a/generateHourlys.php +++ b/generateHourlys.php @@ -1,24 +1,33 @@ prepare("select tgid, extract(hour from call_timestamp) ahour, date_trunc('day', call_timestamp) aday, count(filename), array_to_string(array_agg(filename), ',') filenames from recordings group by tgid, ahour, aday order by aday DESC, ahour, tgid;"); - -$sth->execute(); -$hourlies = $sth->fetchAll(PDO::FETCH_ASSOC); -foreach($hourlies as $hourly) { +function processHourly($hourly) { $filename = $hourly['tgid'].'-'.str_replace(' 00:00:00+1','',$hourly['aday']).'-'.$hourly['ahour'].'.3gp'; if(!file_exists("hourly/".$filename)) { $filenames = explode(",",$hourly['filenames']); - $cmd = "/usr/local/bin/ffmpeg -i data/".implode(" -i data/",$filenames)." -ar 8000 -ab 4.75k -ac 1 hourly/".$filename . ' 2>&1'; - //print_r($hourly); + $cmd = "/usr/local/bin/ffmpeg -i data/".implode(" -i data/",$filenames)." -ar 8000 -ab 4.75k -ac 1 hourly/".$filename . ' 2>&1'; + //print_r($hourly); exec ( $cmd,$output,$returncode ); - echo $cmd.'
'; + echo $cmd."
\n"; if ($returncode != 10) { //print_r($output); //die(); } } } +$sth = $conn->prepare("select tgid, extract(hour from call_timestamp) ahour, date_trunc('day', call_timestamp) aday, count(filename), array_to_string(array_agg(filename order by call_timestamp), ',') filenames from recordings group by tgid, ahour, aday order by aday DESC, ahour, tgid;"); +$sth->execute(); +$hourlies = $sth->fetchAll(PDO::FETCH_ASSOC); +foreach($hourlies as $hourly) { + //processHourly($hourly); +} +$sth = $conn->prepare("select 'hour' as tgid, extract(hour from call_timestamp) ahour, date_trunc('day', call_timestamp) aday, count(filename), array_to_string(array_agg(filename order by call_timestamp), ',') filenames from recordings group by ahour, aday order by aday DESC, ahour;"); +$sth->execute(); +$hourlies = $sth->fetchAll(PDO::FETCH_ASSOC); +foreach($hourlies as $hourly) { + processHourly($hourly); +} + --- a/test.py +++ b/test.py @@ -11,11 +11,17 @@ WAVE_OUTPUT_FILENAME = "output.wav" p = pyaudio.PyAudio() - +device_idx = 0; +for i in range (0, p.get_device_count()): + print(p.get_device_info_by_index(i)) + if p.get_device_info_by_index(i)['name'] == 'Built-in Input': + device_idx = i + print i stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, + input_device_index=device_idx, frames_per_buffer=CHUNK) print("* recording")