2 * Copyright (c) 2010-2024 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.voice.pollytts.internal;
15 import java.io.IOException;
16 import java.io.InputStream;
17 import java.io.OutputStream;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.core.audio.AudioFormat;
22 import org.openhab.core.audio.AudioStream;
25 * Implementation of the {@link AudioStream} interface for the {@link PollyTTSService}.
26 * An AudioStream with an {@link InputStream} inside
28 * @author Robert Hillman - Initial contribution
29 * @author Gwendal Roulleau - Refactor to simple audiostream
32 public class PollyTTSAudioStream extends AudioStream {
34 public InputStream innerInputStream;
35 public AudioFormat audioFormat;
37 public PollyTTSAudioStream(InputStream innerInputStream, AudioFormat audioFormat) {
39 this.innerInputStream = innerInputStream;
40 this.audioFormat = audioFormat;
44 public AudioFormat getFormat() {
49 public int read() throws IOException {
50 return innerInputStream.read();
54 public int read(byte @Nullable [] b) throws IOException {
55 return innerInputStream.read(b);
59 public int read(byte @Nullable [] b, int off, int len) throws IOException {
60 return innerInputStream.read(b, off, len);
64 public byte[] readAllBytes() throws IOException {
65 return innerInputStream.readAllBytes();
69 public byte[] readNBytes(int len) throws IOException {
70 return innerInputStream.readNBytes(len);
74 public int readNBytes(byte @Nullable [] b, int off, int len) throws IOException {
75 return innerInputStream.readNBytes(b, off, len);
79 public long skip(long n) throws IOException {
80 return innerInputStream.skip(n);
84 public int available() throws IOException {
85 return innerInputStream.available();
89 public void close() throws IOException {
90 innerInputStream.close();
94 public synchronized void mark(int readlimit) {
95 innerInputStream.mark(readlimit);
99 public synchronized void reset() throws IOException {
100 innerInputStream.reset();
104 public boolean markSupported() {
105 return innerInputStream.markSupported();
109 public long transferTo(@Nullable OutputStream out) throws IOException {
110 return innerInputStream.transferTo(out);