<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
"""
import os, subprocess

def google_speech(in_file):
    url = ("https://www.google.com/speech-api/v2/recognize?output=json&"
           "lang=en-US&key=<KEY>")
    out_base = os.path.basename(in_file.strip('.flac').strip('.FLAC'))
    out_file = os.path.join(os.path.dirname(in_file), ''.join([out_base,
               '.txt']))
    out_i = 0
    while os.path.exists(out_file):
        out_file = os.path.join(os.path.dirname(in_file), ''.join([out_base,
                   '_', str(out_i), '.json']))
        out_i = out_i + 1
    if not os.path.exists(os.path.dirname(out_file)):
        os.makedirs(out_file)
    command_string = ''.join(["curl -X POST --data-binary @", in_file,
                     " --user-agent 'Mozilla/5.0' --header 'Content-Type:"
                     " audio/x-flac; rate=16000;' '", url, "'"])
    subprocess.call(command_string, shell=True)
    """
    f = open(out_file, 'w')
    print(request.data.decode("utf-8", 'ignore'))
    f.write(request.data.decode("utf-8", 'ignore'))
    """

def main():
    google_speech("/Users/jon.clucas/Documents/recorder_test/"
                  "A001C009_170103PY_CANON.flac")

# ============================================================================
if __name__ == '__main__':
    main()<commit_msg>(Google)<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
"""
import os, subprocess

def google_speech(in_file):
    url = ("https://www.google.com/speech-api/v2/recognize?output=json&"
           "lang=en-US&&pfilter=2&key=<KEY>")
    out_base = os.path.basename(in_file.strip('.flac').strip('.FLAC'))
    out_file = os.path.join(os.path.dirname(in_file), ''.join([out_base,
               '_(Google).json']))
    out_i = 0
    while os.path.exists(out_file):
        out_file = os.path.join(os.path.dirname(in_file), ''.join([out_base,
                   '_', str(out_i), '_(Google).json']))
        out_i = out_i + 1
    if not os.path.exists(os.path.dirname(out_file)):
        os.makedirs(out_file)
    command_string = ''.join(["curl -X POST --data-binary @", in_file,
                     " --user-agent 'Mozilla/5.0' --header 'Content-Type:"
                     " audio/x-flac; rate=44100;' '", url, "' -o ", out_file])
    print(command_string)
    subprocess.call(command_string, shell=True)
    """
    f = open(out_file, 'w')
    print(request.data.decode("utf-8", 'ignore'))
    f.write(request.data.decode("utf-8", 'ignore'))
    """

def main():
    google_speech("/Users/jon.clucas/Documents/recorder_test/"
                  "12_seconds.flac")

# ============================================================================
if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.241593567251462, 'fraction_numerical': 0.015716374269005847, 'mean_word_length': 2.8333333333333335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '927690', 'n_tokens_mistral': 992, 'n_tokens_neox': 942, 'n_words': 130}