<commit_before># -*- coding: utf-8 -*-

# ---------------
# Imports
# ---------------

from __future__ import with_statement, unicode_literals   # Only necessary for Python 2.5
import os
import json
from flask import Flask, request, redirect
from twilio.rest import TwilioRestClient
import twilio.twiml
from twilio.util import TwilioCapability
from urllib import quote_plus
import requests

# ---------------
# Init
# ---------------

app = Flask(__name__)
 
callers = {
    "+17875663317": "Christian",
    "+17879413774": "X",
    "+17874629666": "Abimael"
}

lang1 = ""
lang2 = ""
caller1 = ""
caller2 = ""
text1 = list()
text2 = list()
yandex_key = os.environ.get('YANDEX_API_KEY', '')
att_key = os.environ.get('ATT_KEY', '')

account = os.environ.get('TWILIO_SID', '')
token   = os.environ.get('TWILIO_TOKEN', '')
client  = TwilioRestClient(account, token)

# ---------------
# Helpers
# ---------------

def speech_to_text(speech_url, lang=None):
  data = requests.get(speech_url)
  headers = {
    "Authorization": "Bearer " + att_key,
    "Content-Length": data.headers['content-length'],
    "Content-Type": "audio/x-wav",
    "X-SpeechContext": "Generic",
    "Connection": "keep-alive",
  }
  if lang == 'es':
    headers["Content-Language"] = "es-US"
  text = requests.post("https://api.att.com/speech/v3/speechToText", headers=headers, data=data.content)
  print text.content
  att_data = json.loads(text.content)
  try:
    return json.loads(text.content)[u'Recognition'][u'NBest'][0][u'ResultText']
  except KeyError:
    return "Error"

def translate_text(phrase, from_lang='en', dest_lang='es'):
  url = "https://translate.yandex.net/api/v1.5/tr.json/translate?key=%s&lang=%s-%s&text=%s" % (yandex_key, from_lang, dest_lang, quote_plus(phrase.encode('utf8')))
  translation = requests.get(url)
  return json.loads(translation.content)['text'][0]

def call_number(number):
  global client
  twilio_number = os.environ.get('TWILIO_NUMBER', '')
  ngrok_url = os.environ.get('TWILIO_NGROK', '')
  call = client.calls.create(to = number,
                            from_ = twilio_number,
                            url = ngrok_url + "/call")
  return call.sid
 
# ---------------
# Routes
# ---------------

@app.route("/", methods=['GET', 'POST'])
def hello():
    global caller1<commit_msg>Setting up app.py for heroku<commit_after># -*- coding: utf-8 -*-

# ---------------
# Imports
# ---------------

from __future__ import with_statement, unicode_literals   # Only necessary for Python 2.5
import os
import json
from flask import Flask, request, redirect
from twilio.rest import TwilioRestClient
import twilio.twiml
from twilio.util import TwilioCapability
from urllib import quote_plus
import requests

# ---------------
# Init
# ---------------

app = Flask(__name__)
 
callers = {
    "+17875663317": "Christian",
    "+17879413774": "X",
    "+17874629666": "Abimael"
}

lang1 = ""
lang2 = ""
caller1 = ""
caller2 = ""
text1 = list()
text2 = list()
yandex_key = os.environ.get('YANDEX_API_KEY', '')
att_key = os.environ.get('ATT_KEY', '')

account = os.environ.get('TWILIO_SID', '')
token   = os.environ.get('TWILIO_TOKEN', '')
client  = TwilioRestClient(account, token)

# ---------------
# Helpers
# ---------------

def speech_to_text(speech_url, lang=None):
  data = requests.get(speech_url)
  headers = {
    "Authorization": "Bearer " + att_key,
    "Content-Length": data.headers['content-length'],
    "Content-Type": "audio/x-wav",
    "X-SpeechContext": "Generic",
    "Connection": "keep-alive",
  }
  if lang == 'es':
    headers["Content-Language"] = "es-US"
  text = requests.post("https://api.att.com/speech/v3/speechToText", headers=headers, data=data.content)
  print text.content
  att_data = json.loads(text.content)
  try:
    return json.loads(text.content)[u'Recognition'][u'NBest'][0][u'ResultText']
  except KeyError:
    return "Error"

def translate_text(phrase, from_lang='en', dest_lang='es'):
  url = "https://translate.yandex.net/api/v1.5/tr.json/translate?key=%s&lang=%s-%s&text=%s" % (yandex_key, from_lang, dest_lang, quote_plus(phrase.encode('utf8')))
  translation = requests.get(url)
  return json.loads(translation.content)['text'][0]

def call_number(number):
  global client
  twilio_number = os.environ.get('TWILIO_NUMBER', '')
  call = client.calls.create(to = number,
                            from_ = twilio_number,
                            url = "http://langutalk.herokuapp.com/call")
  return call.sid
 
# ---------------
# Routes
# ---------------

@app.route("/", methods=['GET', 'POST'])
def hello():
    global caller1
{'fraction_non_alphanumeric': 0.20517841601392514, 'fraction_numerical': 0.02132288946910357, 'mean_word_length': 3.1118067978533093, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '266598', 'n_tokens_mistral': 1628, 'n_tokens_neox': 1587, 'n_words': 294}