Post a Local Audio

Sample Java code for sending a local audio file to Nexiwave Speech Indexing Web Service.

(all required Java classes can be downloaded from here: http://nexiwave.com/static/api/sample/java/Client.Sample/lib/)

		SpeechIndexingStub.Add req = new SpeechIndexingStub.Add();

		SpeechIndexingStub.AuthData authData = new SpeechIndexingStub.AuthData();
		authData.setEmail(email);
		authData.setPasswd(passwd);

		req.setAuthData(authData);

		AudioUploadData uploadData = new AudioUploadData();
		uploadData.setMediaFileData(new DataHandler(audio.toURI().toURL()));
		req.setData(uploadData);

		SpeechIndexingStub stub = new SpeechIndexingStub(
				"https://api.nexiwave.com/SpeechIndexing/services/SpeechIndexing");

		// make the call:
		AddResponse resAdd = stub.add(req);

		// obtain response:
		long newRecordingId = resAdd.get_return();
		System.out.println("add result " + newRecordingId);

		if (newRecordingId <= 0)
			throw new RuntimeException("Hmm, invalid recording id returned.");

		return newRecordingId;