package com.nexmo.quickstart.voice;

import com.nexmo.client.NexmoClient;
import com.nexmo.client.auth.AuthMethod;
import com.nexmo.client.auth.JWTAuthMethod;
import com.nexmo.client.voice.Call;
import com.nexmo.client.voice.CallEvent;

import java.nio.file.FileSystems;

import static com.nexmo.quickstart.Util.configureLogging;
import static com.nexmo.quickstart.Util.envVar;

public class SendTalkToCall {
    public static void main(String[] args) throws Exception {
        configureLogging();

        String APPLICATION_ID = envVar("APPLICATION_ID");
        String PRIVATE_KEY = envVar("PRIVATE_KEY");
        String NEXMO_NUMBER = envVar("NEXMO_NUMBER");
        String TO_NUMBER = envVar("TO_NUMBER");

        AuthMethod auth = new JWTAuthMethod(
                APPLICATION_ID,
                FileSystems.getDefault().getPath(PRIVATE_KEY)
        );
        NexmoClient client = new NexmoClient(auth);
        CallEvent call = client.getVoiceClient().createCall(new Call(
                TO_NUMBER,
                NEXMO_NUMBER,
                "https://gist.githubusercontent.com/ChrisGuzman/d6add5b23a8cf913dcdc5a8eabc223ef/raw/a1eb52e0ce2d3cef98bab14d27f3adcdff2af881/long_talk.json"
        ));

        Thread.sleep(20000);

        client.getVoiceClient().startTalk(call.getUuid(), "Hello World! Would you like to know more? I bet you would", 0);
        Thread.sleep(5000);
        client.getVoiceClient().stopTalk(call.getUuid());
    }
}

@@ -71,49 +71,8 @@
 nt;%0A
-import com.nexmo.client.auth.AuthMethod;%0A
 impo
@@ -187,16 +187,57 @@
 llEvent;
+%0Aimport com.nexmo.client.voice.VoiceName;
 %0A%0Aimport
@@ -615,128 +615,61 @@
     
-String NEXMO_NUMBER = envVar(%22NEXMO_NUMBER%22);%0A        String TO_NUMBER = envVar(%22TO_NUMBER%22);%0A%0A        AuthMethod auth =
+NexmoClient client = new NexmoClient(%0A               
  new
@@ -700,16 +700,24 @@
         
+        
 APPLICAT
@@ -740,16 +740,24 @@
         
+ 
+       
 FileSyst
@@ -794,16 +794,34 @@
 TE_KEY)%0A
+                )%0A
         
@@ -823,24 +823,25 @@
      );%0A
+%0A
         
 NexmoCli
@@ -836,49 +836,99 @@
     
-NexmoClient client = new NexmoClient(auth
+String NEXMO_NUMBER = envVar(%22NEXMO_NUMBER%22);%0A        String TO_NUMBER = envVar(%22TO_NUMBER%22
 );%0A 
@@ -1266,57 +1266,59 @@
     
-client.getVoiceClient().startTalk(call.getUuid(),
+String UUID = call.getUuid();%0A        String TEXT =
  %22He
@@ -1377,14 +1377,89 @@
 uld%22
+;%0A        client.getVoiceClient().startTalk(UUID, TEXT, VoiceName.KIMBERLY
 , 0);%0A
+%0A
     
@@ -1523,30 +1523,20 @@
 topTalk(
-call.getUuid()
+UUID
 );%0A    %7D

Clean up for building blocks.