public class SpeechData extends java.io.InputStream implements Value
The stream is allowed to change until it is marked as "final" (i.e. when the audio capture has finished recording).
Constructor and Description |
---|
SpeechData(javax.sound.sampled.AudioFormat format)
Creates a new, empty stream of data with a given audio format
|
SpeechData(byte[] data)
Creates a stream of speech data based on a pre-existing byte array.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Value o)
Returns the hashcode difference.
|
SpeechData |
concatenate(Value value)
Returns the concatenation of the two audio data.
|
boolean |
contains(Value subvalue)
Returns false
|
SpeechData |
copy()
Returns itself
|
javax.sound.sampled.AudioFormat |
getFormat()
Returns the format of the speech data
|
java.util.Collection<Value> |
getSubValues()
Returns an empty list
|
int |
hashCode()
Returns a fixed number (32).
|
boolean |
isFinal()
Returns true if the speech data is final, false otherwise
|
int |
length()
Returns the duration of the audio data (in milliseconds)
|
int |
read()
Reads one byte of the stream
|
int |
read(byte[] buffer,
int offset,
int length)
Reads a buffer of data from the stream
|
void |
rewind()
Resets the current position in the stream to 0.
|
void |
setAsFinal()
Marks the speech data as final (it won't be changed anymore)
|
byte[] |
toByteArray()
Returns the raw array of bytes
|
java.lang.String |
toString()
Returns a string representation of the data
|
void |
write(byte[] buffer)
Expands the current speech data by appending a new buffer of audio data
|
void |
write(java.io.InputStream stream)
Expands the current speech data by appending the data in the input stream.
|
available, close, mark, markSupported, read, reset, skip
public SpeechData(javax.sound.sampled.AudioFormat format)
format
- the audio format to employpublic SpeechData(byte[] data)
data
- the byte arraypublic void setAsFinal()
public void write(byte[] buffer)
buffer
- the new audio data to insertpublic void write(java.io.InputStream stream)
stream
- the stream to add to the speech datapublic int read()
read
in class java.io.InputStream
public int read(byte[] buffer, int offset, int length)
read
in class java.io.InputStream
buffer
- the buffer to filloffset
- the offset at which to start filling the bufferlength
- the maximum number of bytes to readpublic void rewind()
public int length()
public boolean isFinal()
public byte[] toByteArray()
public javax.sound.sampled.AudioFormat getFormat()
public int compareTo(Value o)
compareTo
in interface java.lang.Comparable<Value>
public int hashCode()
public java.lang.String toString()
public SpeechData copy()
public boolean contains(Value subvalue)
public java.util.Collection<Value> getSubValues()
getSubValues
in interface Value
public SpeechData concatenate(Value value)
concatenate
in interface Value
value
- the value to concatenate with the current one