2 * Copyright (c) 2010-2023 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.mactts.internal;
15 import static org.junit.jupiter.api.Assertions.*;
16 import static org.junit.jupiter.api.Assumptions.assumeTrue;
18 import java.io.IOException;
21 import org.junit.jupiter.api.Test;
22 import org.openhab.core.audio.AudioFormat;
23 import org.openhab.core.audio.AudioStream;
24 import org.openhab.core.voice.TTSException;
25 import org.openhab.core.voice.Voice;
28 * Test TTSServiceMacOS
30 * @author Kelly Davis - Initial contribution and API
32 public class TTSServiceMacOSTest {
35 * Test TTSServiceMacOS.getAvailableVoices()
38 public void getAvailableVoicesTest() {
39 assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
41 MacTTSService ttsServiceMacOS = new MacTTSService();
42 assertFalse(ttsServiceMacOS.getAvailableVoices().isEmpty());
46 * Test TTSServiceMacOS.getSupportedFormats()
49 public void getSupportedFormatsTest() {
50 assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
52 MacTTSService ttsServiceMacOS = new MacTTSService();
53 assertFalse(ttsServiceMacOS.getSupportedFormats().isEmpty());
57 * Test TTSServiceMacOS.synthesize(String,Voice,AudioFormat)
60 public void synthesizeTest() throws IOException, TTSException {
61 assumeTrue("Mac OS X".equals(System.getProperty("os.name")));
63 MacTTSService ttsServiceMacOS = new MacTTSService();
64 Set<Voice> voices = ttsServiceMacOS.getAvailableVoices();
65 Set<AudioFormat> audioFormats = ttsServiceMacOS.getSupportedFormats();
66 try (AudioStream audioStream = ttsServiceMacOS.synthesize("Hello", voices.iterator().next(),
67 audioFormats.iterator().next())) {
68 assertNotNull(audioStream, "created null AudioSource");
69 assertNotNull(audioStream.getFormat(), "created an AudioSource w/o AudioFormat");
70 assertNotNull(audioStream, "created an AudioSource w/o InputStream");
71 assertTrue(-1 != audioStream.read(new byte[2]), "returned an AudioSource with no data");