File tree Expand file tree Collapse file tree 10 files changed +74
-19
lines changed Expand file tree Collapse file tree 10 files changed +74
-19
lines changed Original file line number Diff line number Diff line change 11require ( "watson_apis/assistant_v1" )
22
3+ # If using IAM
34assistant = AssistantV1 (
4- # username: "YOUR SERVICE USERNAME",
5- # password: "YOUR SERVICE PASSWORD",
65 iam_api_key : "IAM API KEY" ,
76 version : "2018-02-16"
87)
98
9+ # If you have username & password in your credentials use:
10+ # assistant = AssistantV1(
11+ # username: "YOUR SERVICE USERNAME",
12+ # password: "YOUR SERVICE PASSWORD",
13+ # version: "2018-02-16"
14+ # )
15+
1016#########################
1117# Workspaces
1218#########################
Original file line number Diff line number Diff line change 11require ( "watson_apis/discovery_v1" )
22
3+ # If using IAM
34discovery = WatsonAPIs ::DiscoveryV1 . new (
4- # username: "username",
5- # password: "password",
65 iam_api_key : "IAM API KEY" ,
76 version : "2018-03-05"
87)
98
9+ # If you have username & password in your credentials use:
10+ # discovery = WatsonAPIs::DiscoveryV1.new(
11+ # username: "username",
12+ # password: "password",
13+ # version: "2018-03-05"
14+ # )
15+
1016environments = discovery . list_environments . body
1117p environments
1218
Original file line number Diff line number Diff line change 11require ( "watson_apis/language_translator_v3" )
22
3+ # If using IAM
34language_translator = WatsonAPIs ::LanguageTranslatorV3 . new (
45 version : "2018-05-31" ,
56 ### url is optional, and defaults to the URL below. Use the correct URL for your region.
67 # url: "https://gateway.watsonplatform.net/language-translator/api",
78 iam_api_key : "your_api_key"
89)
910
10- ## Authenticate with username/ password if your service instance doesn't provide an API key
11+ # If you have username & password in your credentials use:
1112# language_translator = WatsonAPIs::LanguageTranslatorV3.new(
1213# version: "2018-05-31",
13- # username: "your_username ",
14- # password: "your_password "
14+ # username: "username ",
15+ # password: "password "
1516# )
1617
1718## Translate
Original file line number Diff line number Diff line change 11require ( "watson_apis/natural_language_classifier_v1" )
22
3+ # If using IAM
34natural_language_classifier = WatsonAPIs ::NaturalLanguageClassifierV1 . new (
4- # username: "YOUR SERVICE USERNAME",
5- # password: "YOUR SERVICE PASSWORD"
65 iam_api_key : "IAM API KEY"
76)
87
8+ # If you have username & password in your credentials use:
9+ # natural_language_classifier = WatsonAPIs::NaturalLanguageClassifierV1.new(
10+ # username: "YOUR SERVICE USERNAME",
11+ # password: "YOUR SERVICE PASSWORD"
12+ # )
13+
914classifiers = natural_language_classifier . list_classifiers . body
1015p classifiers
1116
Original file line number Diff line number Diff line change 11require ( "watson_apis/natural_language_understanding_v1" )
22
3+ # If using IAM
34natural_language_understanding = WatsonAPIs ::NaturalLanguageUnderstandingV1 . new (
4- # username: "YOUR SERVICE USERNAME",
5- # password: "YOUR SERVICE PASSWORD",
65 iam_api_key : "IAM API KEY" ,
76 version : "2018-03-16"
87)
98
9+ # If you have username & password in your credentials use:
10+ # natural_language_understanding = WatsonAPIs::NaturalLanguageUnderstandingV1.new(
11+ # username: "YOUR SERVICE USERNAME",
12+ # password: "YOUR SERVICE PASSWORD",
13+ # version: "2018-03-16"
14+ # )
15+
1016response = natural_language_understanding . analyze (
1117 text : "Bruce Banner is the Hulk and Bruce Wayne is BATMAN! " \
1218 "Superman fears not Banner, but Wayne" ,
Original file line number Diff line number Diff line change 33# The example returns a JSON response whose content is the same as that in
44# ../resources/personality-v3-expect2.txt
55
6+ # If using IAM
67personality_insights = WatsonAPIs ::PersonalityInsightsV3 . new (
7- # username: "YOUR SERVICE USERNAME",
8- # password: "YOUR SERVICE PASSWORD",
98 iam_api_key : "IAM API KEY" ,
109 version : "2017-10-13"
1110)
11+
12+ # If you have username & password in your credentials use:
13+ # personality_insights = WatsonAPIs::PersonalityInsightsV3.new(
14+ # username: "YOUR SERVICE USERNAME",
15+ # password: "YOUR SERVICE PASSWORD",
16+ # version: "2017-10-13"
17+ # )
18+
1219profile = nil
1320File . open ( Dir . getwd + "/resources/personality-v3.json" ) do |profile_json |
1421 profile = personality_insights . profile (
Original file line number Diff line number Diff line change 11require ( "watson_apis/speech_to_text_v1" )
22require ( "watson_apis/recognize_callback" )
33
4+ # If using IAM
45speech_to_text = WatsonAPIs ::SpeechToTextV1 . new (
5- # username: "YOUR SERVICE USERNAME",
6- # password: "YOUR SERVICE PASSWORD"
76 iam_api_key : "IAM API KEY"
87)
98
9+ # If you have username & password in your credentials use:
10+ # speech_to_text = WatsonAPIs::SpeechToTextV1.new(
11+ # username: "YOUR SERVICE USERNAME",
12+ # password: "YOUR SERVICE PASSWORD"
13+ # )
14+
1015p speech_to_text . list_models . body
1116
1217p speech_to_text . get_model ( model_id : "en-US_BroadbandModel" ) . body
Original file line number Diff line number Diff line change 11require ( "watson_apis/text_to_speech_v1" )
22
3+ # If using IAM
34text_to_speech = WatsonAPIs ::TextToSpeechV1 . new (
4- # username: "YOUR SERVICE USERNAME",
5- # password: "YOUR SERVICE PASSWORD"
65 iam_api_key : "IAM API KEY"
76)
87
8+ # If you have username & password in your credentials use:
9+ # text_to_speech = WatsonAPIs::TextToSpeechV1.new(
10+ # username: "YOUR SERVICE USERNAME",
11+ # password: "YOUR SERVICE PASSWORD"
12+ # )
13+
914p text_to_speech . list_voices . body
1015
1116File . new ( "output.wav" , "w+" ) do |audio_file |
Original file line number Diff line number Diff line change 11require ( "watson_apis/tone_analyzer_v3" )
22require ( "json" )
33
4+ # If using IAM
45tone_analyzer = ToneAnalyzerV3 (
5- # username: "YOUR SERVICE USERNAME",
6- # password: "YOUR SERVICE PASSWORD",
76 iam_api_key : "IAM API KEY" ,
87 version : "2017-09-21"
98)
109
10+ # If you have username & password in your credentials use:
11+ # tone_analyzer = ToneAnalyzerV3(
12+ # username: "YOUR SERVICE USERNAME",
13+ # password: "YOUR SERVICE PASSWORD",
14+ # version: "2017-09-21"
15+ # )
16+
1117utterances = [
1218 {
1319 "text" => "I am very happy." ,
Original file line number Diff line number Diff line change 22
33test_url = "https://www.ibm.com/ibm/ginni/images/ginni_bio_780x981_v4_03162016.jpg" . freeze
44
5+ # If using IAM
56visual_recognition = WatsonAPIs ::VisualRecognitionV3 . new (
67 version : "2018-03-19" ,
78 iam_api_key : "IAM API KEY"
89)
910
11+ # If you have username & password in your credentials use:
12+ # visual_recognition = WatsonAPIs::VisualRecognitionV3.new(
13+ # version: "2018-03-19",
14+ # username: "YOUR SERVICE USERNAME",
15+ # password: "YOUR SERVICE PASSWORD"
16+ # )
17+
1018# cars = File.open(Dir.getwd + "/resources/cars.zip")
1119# trucks = File.open(Dir.getwd + "/resources/trucks.zip")
1220# p visual_recognition.create_classifier(
You can’t perform that action at this time.
0 commit comments