Esempio n. 1
0
    def POST(self):
        t = Tropo()

        answer = self.get_answer()

        if re.match("[0-9]{5}", answer):
            pitch_id = answer

            # test that the pitch exists...
            pitch.get_pitch(pitch_id)

            t.say("You want to hear pitch")
            for c in pitch_id:
                t.say(c)

        elif answer in ("0", "random"):
            pitch_id = pitch.random_pitch()['pitch_id']
            if pitch_id:
                # test that the pitch exists...
                pitch.get_pitch(pitch_id)

                t.say("Your random pitch is pitch number")
                for c in pitch_id:
                    t.say(c)
            else:
                t.say("Sorry, no pitches are available yet.")

        elif answer == None:
            return self.do_bad_choice()

        else:
            raise Exception("unexpected answer %s" % answer)

        if pitch_id:
            url = self.s3_url(pitch_id)
            t.say(url)

        t.on(event="continue", next=self.MAIN_MENU)
        return t.RenderJson()
Esempio n. 2
0
    def do_happy(self, pitch_id):
        t = Tropo()
        pitch.confirm_pitch(pitch_id)
        t.say("Great, your pitch has been saved.")

        p = pitch.get_pitch(pitch_id)

        ### @export "send-info-sms"
        call_id = json.loads(web.data())['result']['callId']
        session = pitch.session_info(call_id)

        is_sip = session['caller_network'] == 'SIP'
        is_number = re.match("^(\+)?[0-9]+$", session['caller_id'])

        if is_sip and is_number:
            t.message(
                    """Thank you for using pitchlift!
                    Your Pitch ID is %s.
                    Your PIN is %s.""" % (pitch_id, p['pin']),
                    to=session['caller_id'],
                    channel='TEXT'
                    )

        ### @export "say-info-aloud"
        t.say("Your pitch eye dee is")
        for c in pitch_id:
            t.say(c)
        t.say("Your pin is")
        for c in "%s" % p['pin']:
            t.say(c)
        t.say("once again")
        t.say("Your pitch eye dee is")
        for c in pitch_id:
            t.say(c)
        t.say("Your pin is")
        for c in "%s" % p['pin']:
            t.say(c)

        ### @export "finish"
        t.on(event="continue", next=self.MAIN_MENU)
        return t.RenderJson()
def extract_features(path):
    df = pd.DataFrame()
    print('Extracting features')

    freq_col = ['pitch']
    mfcc_col = ['mfcc' + str(i + 1) for i in list(range(110))]
    col = freq_col + mfcc_col

    directory = os.listdir(path + "recorded_audio\\")
    print(directory)
    for wav_file in directory:
        write_features = []
        y, sr = librosa.load(path + "recorded_audio\\" + wav_file)
        fs, x = wav.read(path + "recorded_audio\\" + wav_file)

        pitch = get_pitch(fs, x)
        mfcc_features = get_mfcc(y, sr)

        write_features = [pitch] + mfcc_features.tolist()[0]
        df = df.append([write_features])
    df.columns = col
    df.to_csv('recorded_audio_features.csv')
Esempio n. 4
0
def main(path, gender):
    df = pd.DataFrame()
    print('Extracting features for ' + gender)

    directory = os.listdir(path)
    for wav_file in directory:
        write_features = []
        y, sr = librosa.load(path + wav_file)
        fs, x = wav.read(path + wav_file)
        print(wav_file)

        pitch = get_pitch(fs, x)
        #frequencies=get_frequencies(y,sr)
        #freq_features=get_features(frequencies)
        mfcc_features = get_mfcc(y, sr)

        #write_features=[pitch]+freq_features+mfcc_features.tolist()[0]+[gender]
        write_features = [pitch] + mfcc_features.tolist()[0] + [gender]
        df = df.append([write_features])
        #if wav_file=='00001.wav':
        #break #remove break to execute for all files
    df.columns = col
    df.to_csv(gender + '_features.csv')