Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update watson-transcribe.py #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions auth.cfg.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[watson]
username = UUID
password = pass
iam_apikey = "Place your api key here"
url = "Place the url provided on the credentials page here"
18 changes: 9 additions & 9 deletions watson-transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
# under the License.

import argparse
import ConfigParser
import configparser
import json
from os.path import join, dirname
from watson_developer_cloud import SpeechToTextV1


def get_auth():
config = ConfigParser.RawConfigParser()
config = configparser.RawConfigParser()
config.read('auth.cfg')
user = config.get('watson', 'username')
password = config.get('watson', 'password')
return (user, password)
iam_apikey = config.get('watson', 'iam_apikey')
url = config.get('watson', 'url')
return (iam_apikey, url)


def parse_args():
Expand All @@ -41,9 +41,9 @@ def main():
args = parse_args()
(user, passwd) = get_auth()
speech_to_text = SpeechToTextV1(
username=user,
password=passwd,
x_watson_learning_opt_out=False
iam_apikey=user,
url=passwd,

)

speech_to_text.get_model('en-US_BroadbandModel')
Expand All @@ -59,7 +59,7 @@ def main():
word_confidence=True)
with open("watson-transcript.json", "w") as out:
print("Transcription done, written to watson-transcription.json")
out.write(json.dumps(output, indent=2))
out.write(json.dumps(output.get_result(), indent=2))

if __name__ == "__main__":
main()