Skip to content

Commit 8c3653d

Browse files
apaparazzi0329jeff-arn
authored andcommitted
refactor(stt): remove unused variable tokenUrl
1 parent 3530877 commit 8c3653d

3 files changed

Lines changed: 2 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ VisualRecognitionV4 added :tada:
815815

816816

817817
### SpeechToTextV1
818-
- The `tokenURL` and `websocketsURL` properties are no longer public. Setting the `serviceURL` will automatically update the other two URLs appropriately.
818+
- The `websocketsURL` property is no longer public. Setting the `serviceURL` will automatically update the property.
819819
- Add missing parameters `baseModelVersion`, `languageCustomizationID`, and `customerID` to the following methods:
820820
- `recognize()` (using an audio file)
821821
- `recognizeUsingWebsocket()`

Sources/SpeechToTextV1/WebSockets/SpeechToTextSession.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,19 @@ public class SpeechToTextSession {
3636
/// The URL that shall be used to stream audio for transcription.
3737
public var websocketsURL = "wss://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/recognize" {
3838
didSet {
39-
// serviceURL and tokenURL are both derivative of websocketsURL
39+
// serviceURL is a derivative of websocketsURL
4040
if websocketsURL.last == "/" {
4141
websocketsURL.removeLast()
4242
}
4343
serviceURL = websocketsURL
4444
.replacingOccurrences(of: "ws", with: "http", options: .anchored, range: nil)
4545
.replacingOccurrences(of: "/v1/recognize", with: "")
46-
tokenURL = serviceURL.replacingOccurrences(of: "/speech-to-text/api", with: "/authorization/api/v1/token")
4746
}
4847
}
4948

5049
/// The base URL of the Speech to Text service.
5150
internal var serviceURL = "https://api.us-south.speech-to-text.watson.cloud.ibm.com"
5251

53-
/// The URL that shall be used to obtain a token.
54-
internal var tokenURL = "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/token"
55-
5652
/// The default HTTP headers for all requests to the service.
5753
public var defaultHeaders = [String: String]()
5854

Tests/SpeechToTextV1Tests/SpeechToTextUnitTests.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,6 @@ class SpeechToTextUnitTests: XCTestCase {
5555
XCTAssertEqual(speechToTextSession.serviceURL, "https://example.com/speech-to-text/api")
5656
}
5757

58-
func testWebsocketsURLSetsTokenURL() {
59-
let apiKey = "your-api-key"
60-
let speechToTextSession = SpeechToTextSession(authenticator: defaultTestAuthenticator)
61-
62-
// Default URLs value
63-
XCTAssertEqual(speechToTextSession.websocketsURL, "wss://api.us-south.speech-to-text.watson.cloud.ibm.com/recognize")
64-
XCTAssertEqual(speechToTextSession.tokenURL, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/authorization/api/v1/token")
65-
66-
// Set websockets URL and verify tokenURL
67-
speechToTextSession.websocketsURL = "wss://api.au-syd.speech-to-text.watson.cloud.ibm.com/v1/recognize"
68-
XCTAssertEqual(speechToTextSession.tokenURL, "https://api.au-syd.speech-to-text.watson.cloud.ibm.com/authorization/api/v1/token")
69-
70-
// http instead of https
71-
speechToTextSession.websocketsURL = "ws://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/recognize"
72-
XCTAssertEqual(speechToTextSession.tokenURL, "http://api.us-south.speech-to-text.watson.cloud.ibm.com/authorization/api/v1/token")
73-
74-
// Different base URL
75-
speechToTextSession.websocketsURL = "wss://example.com/speech-to-text/api/v1/recognize/v1/recognize"
76-
XCTAssertEqual(speechToTextSession.tokenURL, "https://example.com/authorization/api/v1/token")
77-
}
78-
7958
// MARK: - Websockets
8059

8160
// Check that instantiating a SpeechToTextSession creates the correct SpeechToTextSocket

0 commit comments

Comments
 (0)