wit 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 282eac4ad9cd9d938056b482a5eb8e434becdfd3
4
- data.tar.gz: 9ad5a19951d7042d9e2fd2f290abb1b7a36ac244
3
+ metadata.gz: ca7043e6f072014963a1d0dd2a7e13239a635706
4
+ data.tar.gz: 58c178c79436cad62d2585900c14a9118dcb81c4
5
5
  SHA512:
6
- metadata.gz: 3b29fc3d72cf17d1d5e983b4cbfd23cea0cd8fc4f498b7e2707e022ca77c4e1411203a9db6f517e4ebc1391882b3ab63ea8991022db4bdc2eda017c3d596d00e
7
- data.tar.gz: fc1d3def4cac9f9c24cba7cb8f3c689288543a111f1f198cb3c6369d43f754ca3f8fd7a43f11fcb2b442e39c2ba269a03e0853b90d09bda012297cae17ee3d6a
6
+ metadata.gz: 1625bb89509f6a00a1fecdef7407ba6167d8f731ba3278fd9f037dd011bca5fba01089528bd6c39f280c2a412d6515eb83a77c347e4a587452a3c4f91177ee22
7
+ data.tar.gz: 8e7a23afeb5e1eeb44044f940b77936286e2cc3e0f37133ef56f63f900d891441f9a70cdc5969614c93d6e133b7b4550eaf2119ce9603c851733b9dce6b876c5
data/ext/wit/extconf.rb CHANGED
@@ -2,19 +2,6 @@ require "mkmf"
2
2
 
3
3
  PATH = File.expand_path(File.dirname(__FILE__))
4
4
 
5
- abort "missing Cargo (http://crates.io)" unless system("cargo")
6
-
7
- if not File.exist?(PATH + '/libwit')
8
- p "Cloning libwit repository..."
9
- abort "unable to clone libwit repository" unless system("git clone https://github.com/wit-ai/libwit.git", :chdir=> PATH)
10
- p "Updating libwit..."
11
- abort "unable to update libwit repository" unless system("git pull", :chdir=> PATH + "/libwit")
12
- end
13
- if not (File.exist?(PATH + '/libwit/include/libwit.a') and File.exist?(PATH + '/libwit/lib/wit.h'))
14
- p "Compiling libwit..."
15
- abort "could not build libwit" unless system("./build_c.sh;", :chdir=> PATH + "/libwit")
16
- end
17
-
18
5
  LIBDIR = RbConfig::CONFIG['libdir']
19
6
  INCLUDEDIR = RbConfig::CONFIG['includedir']
20
7
  HEADER_DIRS = [
@@ -26,11 +13,23 @@ LIB_DIRS = [
26
13
  LIBDIR
27
14
  ]
28
15
 
16
+ if RUBY_PLATFORM.include? 'arm'
17
+ system('ln -s libwit-armv6.a libwit.a', :chdir=> PATH + '/libwit/lib')
18
+ elsif RUBY_PLATFORM.include? '64'
19
+ if RUBY_PLATFORM.include? 'darwin'
20
+ system('ln -s libwit-64-darwin.a libwit.a', :chdir=> PATH + '/libwit/lib')
21
+ else
22
+ system('ln -s libwit-64-linux.a libwit.a', :chdir=> PATH + '/libwit/lib')
23
+ end
24
+ else
25
+ system('ln -s libwit-32-linux.a libwit.a', :chdir=> PATH + '/libwit/lib')
26
+ end
27
+
29
28
  $LOCAL_LIBS = '-lwit -lsox -lcurl'
30
29
 
31
30
  dir_config 'wit', HEADER_DIRS, LIB_DIRS
32
31
 
33
32
  abort "missing wit.h" unless have_header "wit.h"
34
- abort "missing libwit" unless have_library "wit", "wit_init"
33
+ abort "missing libwit" unless have_library "wit"
35
34
 
36
35
  create_makefile "wit"
@@ -0,0 +1,81 @@
1
+ #ifndef WIT_H
2
+ #define WIT_H
3
+
4
+ #include <stdlib.h>
5
+
6
+ struct wit_context;
7
+ typedef void (*wit_resp_callback)(char *);
8
+
9
+ /**
10
+ * Initialize the resources for audio recording and Wit API requests.
11
+ * This function returns a context object used by all the other functions
12
+ * in the library.
13
+ * The resources can be released using wit_close.
14
+ */
15
+ struct wit_context *wit_init(const char *device_opt, unsigned int verbosity);
16
+
17
+ /**
18
+ * Release the resources allocated by wit_init.
19
+ * The context object should not be used for any other purpose after this function
20
+ * has been called.
21
+ */
22
+ void wit_close(struct wit_context *context);
23
+
24
+ /**
25
+ * Send a text query to the Wit instance identified by the access_token.
26
+ * This function is blocking, and returns the response from the Wit instance.
27
+ */
28
+ char *wit_text_query(struct wit_context *context, const char *text, const char *access_token);
29
+
30
+ /**
31
+ * Send a text query to the Wit instance identified by the access_token.
32
+ * This function is non-blocking. When a response is received from the Wit instance, the
33
+ * given callback is called with the response given as an argument.
34
+ */
35
+ void wit_text_query_async(struct wit_context *context, const char *text, const char *access_token, wit_resp_callback cb);
36
+
37
+ /**
38
+ * Send a voice query to the Wit instance identified by the access_token.
39
+ * This function is blocking, and returns the response from the Wit instance.
40
+ *
41
+ * The function attempts to automatically detect when the user stops speaking. If this
42
+ * fails, the wit_voice_query_stop or wit_voice_query_stop_async functions below can
43
+ * be used to trigger the end of the request and receive the response.
44
+ */
45
+ char *wit_voice_query_auto(struct wit_context *context, const char *access_token);
46
+
47
+ /**
48
+ * Send a voice query to the Wit instance identified by the access_token.
49
+ * This function is non-blocking. When a response is received from the Wit instance, the
50
+ * given callback is called with the response given as an argument.
51
+ *
52
+ * The function attempts to automatically detect when the user stops speaking. If this
53
+ * fails, the wit_voice_query_stop or wit_voice_query_stop_async functions below can
54
+ * be used to trigger the end of the request and receive the response.
55
+ */
56
+ void wit_voice_query_auto_async(struct wit_context *context, const char *access_token, wit_resp_callback cb);
57
+
58
+ /**
59
+ * Send a voice query to the Wit instance identified by the access_token.
60
+ * This function returns immediately: the recording session stops only when either
61
+ * wit_voice_query_stop or wit_voice_query_stop_async is called. No end-of-speech
62
+ * detection is performed.
63
+ */
64
+ void wit_voice_query_start(struct wit_context *context, const char *access_token);
65
+
66
+ /**
67
+ * Stop the ongoing recording session and receive the response.
68
+ * This function is blocking, and returns the response from the Wit instance.
69
+ * This function has no effect if there is no ongoing recording session.
70
+ */
71
+ char *wit_voice_query_stop(struct wit_context *context);
72
+
73
+ /**
74
+ * Stop the ongoing recording session and receive the response.
75
+ * This function is non-blocking. When a response is received from the Wit instance, the
76
+ * given callback is called with the response given as an argument.
77
+ * This function has no effect if there is no ongoing recording session.
78
+ */
79
+ void wit_voice_query_stop_async(struct wit_context *context, wit_resp_callback cb);
80
+
81
+ #endif
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Odent
@@ -18,6 +18,11 @@ extensions:
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - ext/wit/extconf.rb
21
+ - ext/wit/libwit/include/wit.h
22
+ - ext/wit/libwit/lib/libwit-32-linux.a
23
+ - ext/wit/libwit/lib/libwit-64-darwin.a
24
+ - ext/wit/libwit/lib/libwit-64-linux.a
25
+ - ext/wit/libwit/lib/libwit-armv6.a
21
26
  - ext/wit/wit.c
22
27
  homepage: http://wit.ai
23
28
  licenses:
@@ -31,7 +36,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
31
36
  requirements:
32
37
  - - ">="
33
38
  - !ruby/object:Gem::Version
34
- version: '0'
39
+ version: 2.1.1
35
40
  required_rubygems_version: !ruby/object:Gem::Requirement
36
41
  requirements:
37
42
  - - ">="