Package ai.rev.speechtotext
Class StreamingClient
- java.lang.Object
-
- ai.rev.speechtotext.StreamingClient
-
public class StreamingClient extends Object
-
-
Constructor Summary
Constructors Constructor Description StreamingClient(String accessToken)Constructs the streaming client that is used to establish a WebSocket connection with the Rev AI server and stream audio data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Will close the WebSocket connection by informing the server that it's the End of Streamvoidconnect(RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType)Overload ofconnect(RevAiWebSocketListener, StreamContentType, String, SessionConfig)without the optional metadata and sessionConfig.voidconnect(RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType, SessionConfig sessionConfig)Overload ofconnect(RevAiWebSocketListener, StreamContentType, String, SessionConfig)without the optional metadata.voidconnect(RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType, String metadata)Overload ofconnect(RevAiWebSocketListener, StreamContentType, String, SessionConfig)without the optional sessionConfig.voidconnect(RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType, String metadata, SessionConfig sessionConfig)Sends an HTTP request and upon authorization is upgraded to a WebSocket connection.voidsendAudioData(okio.ByteString byteString)Sends data over WebSocket in the form of a ByteStringvoidsetHost(String host)This methods sets the URL host name.voidsetPort(int port)This method sets a port number to be used in the WebSocket connect request.voidsetScheme(String scheme)This method sets the URL scheme to be used in the WebSocket connect request
-
-
-
Constructor Detail
-
StreamingClient
public StreamingClient(String accessToken)
Constructs the streaming client that is used to establish a WebSocket connection with the Rev AI server and stream audio data. The user access token can be generated on the website at https://www.rev.ai/access_token.- Parameters:
accessToken- Rev AI authorization token.
-
-
Method Detail
-
setScheme
public void setScheme(String scheme)
This method sets the URL scheme to be used in the WebSocket connect request- Parameters:
scheme- URL scheme.
-
setHost
public void setHost(String host)
This methods sets the URL host name. By default the host name is api.rev.ai.- Parameters:
host- URL host name.
-
setPort
public void setPort(int port)
This method sets a port number to be used in the WebSocket connect request.- Parameters:
port- the port used to connect to
-
connect
public void connect(RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType, String metadata, SessionConfig sessionConfig)
Sends an HTTP request and upon authorization is upgraded to a WebSocket connection. UseRevAiWebSocketListenerto handle web socket events. To establish a successful connection a valid StreamContentType must be provided.Providing metadata is optional but helps to identify the stream.
Providing a
SessionConfigis optional. Use this object to enable the profanity filter and provide a custom vocabulary id.- Parameters:
revAiWebSocketListener- the listener used to capture WebSocket events.streamContentType- content-type query parameter.metadata- used to identify the stream.sessionConfig- object containing the filter profanity setting and custom vocabulary id- See Also:
RevAiWebSocketListener,StreamContentType,SessionConfig
-
connect
public void connect(RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType)
Overload ofconnect(RevAiWebSocketListener, StreamContentType, String, SessionConfig)without the optional metadata and sessionConfig.
-
connect
public void connect(RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType, String metadata)
Overload ofconnect(RevAiWebSocketListener, StreamContentType, String, SessionConfig)without the optional sessionConfig.
-
connect
public void connect(RevAiWebSocketListener revAiWebSocketListener, StreamContentType streamContentType, SessionConfig sessionConfig)
Overload ofconnect(RevAiWebSocketListener, StreamContentType, String, SessionConfig)without the optional metadata.
-
sendAudioData
public void sendAudioData(okio.ByteString byteString)
Sends data over WebSocket in the form of a ByteString- Parameters:
byteString- Audio data in the form of a ByteString
-
close
public void close()
Will close the WebSocket connection by informing the server that it's the End of Stream
-
-