<commit_before>from django.http import HttpResponse
from django.template.loader import render_to_string
from django.urls import reverse
from django.views.generic.edit import FormView

from twilio.twiml.voice_response import Gather, VoiceResponse

from emojiweather.mixins import CsrfExemptMixin
from .forms import VoiceWeatherForm


class VoiceView(CsrfExemptMixin, FormView):
    template_name = 'voice/voice.html'
    form_class = VoiceWeatherForm

    def form_valid(self, form):
        if form.cleaned_data['SpeechResult']:
            address = form.cleaned_data['SpeechResult']
        elif form.cleaned_data['Digits']:
            address = form.cleaned_data['Digits']
        else:
            address = '%s %s %s %s' % (
                form.cleaned_data['FromCity'],
                form.cleaned_data['FromState'],
                form.cleaned_data['FromZip'],
                form.cleaned_data['FromCountry'],
            )
            address = address.strip()
        context = {'results': form.get_results(address)}
        message = render_to_string('voice/voice.xml', context)
        response = VoiceResponse()
        gather = Gather(input='dtmf speech', timeout=2, numDigits=5)
        gather.say(message, voice='alice')
        response.append(gather)
        response.redirect(reverse('voice'))
        return HttpResponse(response, content_type='text/xml')
<commit_msg>Made the phone go faster<commit_after>from django.http import HttpResponse
from django.template.loader import render_to_string
from django.urls import reverse
from django.views.generic.edit import FormView

from twilio.twiml.voice_response import Gather, VoiceResponse

from emojiweather.mixins import CsrfExemptMixin
from .forms import VoiceWeatherForm


class VoiceView(CsrfExemptMixin, FormView):
    template_name = 'voice/voice.html'
    form_class = VoiceWeatherForm

    def form_valid(self, form):
        if form.cleaned_data['SpeechResult']:
            address = form.cleaned_data['SpeechResult']
        elif form.cleaned_data['Digits']:
            address = form.cleaned_data['Digits']
        else:
            address = '%s %s %s %s' % (
                form.cleaned_data['FromCity'],
                form.cleaned_data['FromState'],
                form.cleaned_data['FromZip'],
                form.cleaned_data['FromCountry'],
            )
            address = address.strip()
        context = {'results': form.get_results(address)}
        message = render_to_string('voice/voice.xml', context)
        response = VoiceResponse()
        gather = Gather(input='dtmf speech', timeout=0, numDigits=5)
        gather.say(message, voice='alice')
        response.append(gather)
        response.redirect(reverse('voice'))
        return HttpResponse(response, content_type='text/xml')

{'fraction_non_alphanumeric': 0.10447227191413237, 'fraction_numerical': 0.0014311270125223613, 'mean_word_length': 2.9659574468085106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '92390', 'n_tokens_mistral': 802, 'n_tokens_neox': 792, 'n_words': 162}