我目前正致力于nexmo语音通话项目,方案是从通话中获取实时数据并将数据传输到https://www.voicebase.com/
,VoiceBase
将计算会话的情绪分数。我使用下面的代码创建了这个电话,
public class NexmoCall {
public static void main(String[] args) {
JWTAuthMethod auth;
try {
JSONParser parser = new JSONParser();
JSONArray jsonArray = (JSONArray) parser.parse(new FileReader("talk.json"));
System.out.println(new Gson().toJson(jsonArray));
File fileReader = new File("private_new.pem");
System.out.println(Paths.get(fileReader.getAbsolutePath()));
auth = new JWTAuthMethod("secretKey", Paths.get(fileReader.getAbsolutePath()));
NexmoClient client = new NexmoClient(auth);
Call call = new Call("+fromno", "tonumber", jsonArray.toString());
CallEvent event = client.getVoiceClient().createCall(call);
//VerifyResult request = client.getVerifyClient().verify("+919884474072", "MyApp");
//CallInfo info = client.getVoiceClient().getCallDetails(event.getUuid());
DtmfResponse dtmfResponse = client.getVoiceClient().sendDtmf(event.getUuid(), "332393");
System.out.println("Success! " + dtmfResponse.getMessage());
} catch (InvalidKeyException | NoSuchAlgorithmException | InvalidKeySpecException | IOException | ParseException
| NexmoClientException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}