src/main/java/com/ttsplugin/main/TTSPlugin.java
/**
	 * Plays the text with the specified voice and distance
	 */
Plays the text with the specified voice and distance
Plays the text with the specified voice and distance
public void play(TTSMessage message) {
		try {
			String request = "https://ttsplugin.com?m=" + URLEncoder.encode(message.message, "UTF-8") + "&r=" + config.rate() + "&v=" + message.voice;
		    URLConnection conn = new URL(request).openConnection();
		    byte[] bytes = new byte[conn.getContentLength()];
		    InputStream stream = conn.getInputStream();
		    for (int i = 0; i < conn.getContentLength(); i++) {
		    	bytes[i] = (byte)stream.read();
		    }
			AudioInputStream inputStream = AudioSystem.getAudioInputStream(new ByteArrayInputStream(bytes));
			Clip clip = AudioSystem.getClip();
	        clip.open(inputStream);
	        currentClip = clip;
	        if (config.distanceVolume()) {
	        	Utils.setClipVolume((config.volume() / (float)10) - ((float)message.distance / (float)config.distanceVolumeEffect()), clip);
	        } else {
	        	Utils.setClipVolume(config.volume() / (float)10, clip);
	        }
	        clip.start();
			Utils.sleep(50);
			while(clip.isRunning())  {
				Utils.sleep(50);
				if (client.getGameState() == GameState.LOGIN_SCREEN || queueThread == null) {
					clip.stop();
					break;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
public void play ( TTSMessage message ) { try { String request = "https://ttsplugin.com?m=" + URLEncoder . encode ( message . message , "UTF-8" ) + "&r=" + config . rate ( ) + "&v=" + message . voice ; URLConnection conn = new URL ( request ) . openConnection ( ) ; byte [ ] bytes = new byte [ conn . getContentLength ( ) ] ; InputStream stream = conn . getInputStream ( ) ; for ( int i = 0 ; i < conn . getContentLength ( ) ; i ++ ) { bytes [ i ] = ( byte ) stream . read ( ) ; } AudioInputStream inputStream = AudioSystem . getAudioInputStream ( new ByteArrayInputStream ( bytes ) ) ; Clip clip = AudioSystem . getClip ( ) ; clip . open ( inputStream ) ; currentClip = clip ; if ( config . distanceVolume ( ) ) { Utils . setClipVolume ( ( config . volume ( ) / ( float ) 10 ) - ( ( float ) message . distance / ( float ) config . distanceVolumeEffect ( ) ) , clip ) ; } else { Utils . setClipVolume ( config . volume ( ) / ( float ) 10 , clip ) ; } clip . start ( ) ; Utils . sleep ( 50 ) ; while ( clip . isRunning ( ) ) { Utils . sleep ( 50 ) ; if ( client . getGameState ( ) == GameState . LOGIN_SCREEN || queueThread == null ) { clip . stop ( ) ; break ; } } } catch ( Exception e ) { e . printStackTrace ( ) ; } }
Plays the text with the specified voice and distance
Plays the text with the specified voice and distance