<commit_before>import os
import wave
from glob import glob

import pyaudio
import pyee
from os.path import dirname, join
from speech_recognition import Microphone, AudioSource

from mycroft.client.speech.listener import AudioConsumer
from mycroft.client.speech.local_recognizer import LocalRecognizer
from mycroft.client.speech.mic import MutableStream, ResponsiveRecognizer
from mycroft.util.log import getLogger
from mycroft.client.speech.mic import logger as speech_logger

__author__ = 'wolfgange3311999'
logger = getLogger('audio_test_runner')


class MockStream(object):
    def __init__(self, file_name):
        self.file = wave.open(file_name, 'rb')
        self.size = self.file.getnframes()
        self.sample_rate = self.file.getframerate()
        self.sample_width = self.file.getsampwidth()

    def read(self, chunk_size):
        if abs(self.file.tell() - self.size) < 10:
            raise EOFError
        return self.file.readframes(chunk_size)

    def close(self):
        self.file.close()


class MockMicrophone(AudioSource):
    def __init__(self, file_name):
        self.stream = MockStream(file_name)
        self.SAMPLE_RATE = self.stream.sample_rate
        self.SAMPLE_WIDTH = self.stream.sample_width
        self.CHUNK = 1024

    def close(self):
        self.stream.close()


class AudioTester(object):
    def __init__(self, samp_rate):
        self.ww_recognizer = LocalRecognizer(samp_rate, 'en-us')
        self.listener = ResponsiveRecognizer(self.ww_recognizer)
        speech_logger.setLevel(100)  # Disables logging to clean output

    @staticmethod
    def absolute_path(name):
        root_dir = dirname(dirname(__file__))
        return join(root_dir, 'audio-test', 'data', name)

    def test_audio(self, file_name):
        source = MockMicrophone(file_name)
        ee = pyee.EventEmitter()
<commit_msg>changed audio test directory<commit_after>import os
import wave
from glob import glob

import pyaudio
import pyee
from os.path import dirname, join
from speech_recognition import Microphone, AudioSource

from mycroft.client.speech.listener import AudioConsumer
from mycroft.client.speech.local_recognizer import LocalRecognizer
from mycroft.client.speech.mic import MutableStream, ResponsiveRecognizer
from mycroft.util.log import getLogger
from mycroft.client.speech.mic import logger as speech_logger

__author__ = 'wolfgange3311999'
logger = getLogger('audio_test_runner')


class MockStream(object):
    def __init__(self, file_name):
        self.file = wave.open(file_name, 'rb')
        self.size = self.file.getnframes()
        self.sample_rate = self.file.getframerate()
        self.sample_width = self.file.getsampwidth()

    def read(self, chunk_size):
        if abs(self.file.tell() - self.size) < 10:
            raise EOFError
        return self.file.readframes(chunk_size)

    def close(self):
        self.file.close()


class MockMicrophone(AudioSource):
    def __init__(self, file_name):
        self.stream = MockStream(file_name)
        self.SAMPLE_RATE = self.stream.sample_rate
        self.SAMPLE_WIDTH = self.stream.sample_width
        self.CHUNK = 1024

    def close(self):
        self.stream.close()


class AudioTester(object):
    def __init__(self, samp_rate):
        self.ww_recognizer = LocalRecognizer(samp_rate, 'en-us')
        self.listener = ResponsiveRecognizer(self.ww_recognizer)
        speech_logger.setLevel(100)  # Disables logging to clean output

    @staticmethod
    def absolute_path(name):
        root_dir = dirname(dirname(__file__))
        return join(root_dir, 'audio-test', 'data', 'query_after', name)

    def test_audio(self, file_name):
        source = MockMicrophone(file_name)
        ee = pyee.EventEmitter()

{'fraction_non_alphanumeric': 0.09122525414660246, 'fraction_numerical': 0.008560727661851257, 'mean_word_length': 3.532121212121212, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6622351', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1122, 'n_words': 256}