Exemplo n.º 1
0
def transcribe_audio(path_to_audio_file):
    username = os.environ.get("BLUEMIX_USERNAME")
    password = os.environ.get("BLUEMIX_PASSWORD")
    speech_to_text = SpeechToText(username=username, password=password)

    with open(join(dirname(__file__), path_to_audio_file), 'rb') as audio_file:
        return speech_to_text.recognize(audio_file, content_type='audio/wav')
Exemplo n.º 2
0
def transcribe_audio(path_to_audio_file):
    username = "******"
    password = "******"
    speech_to_text = SpeechToText(username=username, password=password)

    with open(path_to_audio_file, 'rb') as audio_file:
        return speech_to_text.recognize(audio_file, content_type='audio/wav')
Exemplo n.º 3
0
def transcribe_audio(path_to_audio_file):
    username = config.SPEECH_TO_TEXT_USERNAME
    password = config.SPEECH_TO_TEXT_PASSWORD
    speech_to_text = SpeechToText(username=username, password=password)

    with open(join(dirname(__file__), path_to_audio_file), 'rb') as audio_file:
        return speech_to_text.recognize(audio_file, content_type='audio/wav')
Exemplo n.º 4
0
def transcribe_audio(audio_file, extension, model):

    username = os.environ.get("BLUEMIX-STT-USERNAME")
    password = os.environ.get("BLUEMIX-STT-PASSWORD")

    speech_to_text = SpeechToText(
        username = username,
        password = password,
        x_watson_learning_opt_out = False,
    )
    with open(audio_file, "rb") as audio:
        try:
            result = speech_to_text.recognize(
                audio,
                content_type = "audio/" + extension,
                model = model
            )
        except Exception as ex:
            print(ex)
            raise
    try:
        transcripted_text = result["results"][0]["alternatives"][0]["transcript"]
    except:
        print("I'm sorry, the audio is blank! If youre sure that there was"
            "an audio, it probably was below the microphone sensibility. Try "
            "speaking louder.")
        raise
    return transcripted_text.rstrip()
def transcribe_audio(path_to_audio_file):
    # enter your info here
    username = ""
    password = ""
    speech_to_text = SpeechToText(username=username, password=password)

    with open(path_to_audio_file, 'rb') as audio_file:
        return speech_to_text.recognize(audio_file, content_type='audio/wav')
Exemplo n.º 6
0
def transcribe_audio(path_to_audio_file):
    username = os.environ.get("BLUEMIX_USERNAME")
    password = os.environ.get("BLUEMIX_PASSWORD")
    speech_to_text = SpeechToText(username=username,
                                  password=password)

    with open(join(dirname(__file__), path_to_audio_file), 'rb') as audio_file:
        return speech_to_text.recognize(audio_file,
            content_type='audio/wav')
Exemplo n.º 7
0
    def transcribe_audio(self, path_to_audio_file):
        #username = os.environ.get("BLUEMIX_USERNAME")
        #password = os.environ.get("BLUEMIX_PASSWORD")
        username = "******"
        password = "******"
        speech_to_text = SpeechToText(username=username, password=password)

        with open(path_to_audio_file, 'rb') as audio_file:
            return speech_to_text.recognize(audio_file,
                                            content_type='audio/wav')
Exemplo n.º 8
0
class SpeechText(object):
    def __init__(self):
        self.STT = SpeechToText(
            username='******',
            password='******')
        self.TTS = TextToSpeech(
            username='******',
            password='******')

    def transcribe_audio(self, audio_file):
        return self.STT.recognize(
            audio_file, content_type='audio/wav'
        )['results'][0]['alternatives'][0]['transcript']

    def speak_text(self, text):
        return self.TTS.synthesize(text, accept='audio/wav')
Exemplo n.º 9
0
    def speech_to_text(self, wavpath):
        username = self.speechcreds['username']
        password = self.speechcreds['password']

        speech_to_text = SpeechToText(username=username,
                                      password=password)

        result = ""
        fname = wavpath

        try:
            with open(fname, 'rb') as audio_file:
                result = speech_to_text.recognize(audio_file,
                                                  content_type='audio/wav')

            text = result['results'][0]['alternatives'][0]['transcript']
            return text
        except:
            return "Something went wrong. Please try again."
Exemplo n.º 10
0
import json
from os.path import join, dirname
from watson_developer_cloud import SpeechToTextV1 as SpeechToText

speech_to_text = SpeechToText(username='******',
                              password='******')

print(json.dumps(speech_to_text.models(), indent=2))

with open(join(dirname(__file__), '../resources/speech.wav'),
          'rb') as audio_file:
    print(
        json.dumps(speech_to_text.recognize(audio_file,
                                            content_type='audio/wav'),
                   indent=2))
Exemplo n.º 11
0
def transcribe_audio(path_to_audio_file):
    username = "******"
    password = "******"
    speech_to_text = SpeechToText(username=username, password=password)
    with open(path_to_audio_file, 'rb') as audio_file:
        return speech_to_text.recognize(audio_file, content_type='audio/wav')
Exemplo n.º 12
0
import json
from os.path import join, dirname
from watson_developer_cloud import SpeechToTextV1 as SpeechToText


speech_to_text = SpeechToText(username='******',
                              password='******')

print(json.dumps(speech_to_text.models(), indent=2))

with open(join(dirname(__file__), '../resources/speech.wav'), 'rb') as audio_file:
    print(json.dumps(speech_to_text.recognize(audio_file,
                                              content_type='audio/wav'), indent=2))