pangdudu-swiftly 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/Swiftly.c ADDED
@@ -0,0 +1,47 @@
1
+ // Include the Ruby headers and goodies
2
+ #include "ruby.h"
3
+ #include <stdio.h>
4
+ #include <stdlib.h>
5
+ #include <string.h>
6
+ #include "../external/include/swift.h"
7
+
8
+ // Defining a space for information and references about the module to be stored internally
9
+ VALUE Swiftly = Qnil;
10
+
11
+ // Prototype for the initialization method - Ruby calls this, not you
12
+ void Init_swiftly();
13
+
14
+ // Prototype for our method 'speak' - methods are prefixed by 'method_' here
15
+ VALUE method_speak(VALUE self, VALUE text);
16
+
17
+ // The initialization method for this module
18
+ void Init_swiftly() {
19
+ Swiftly = rb_define_module("Swiftly");
20
+ rb_define_method(Swiftly, "speak", method_speak, 1);
21
+ }
22
+
23
+ // Our 'speak' method
24
+ VALUE method_speak(VALUE self, VALUE text) {
25
+ char* ctext = STR2CSTR(text);
26
+ swift_engine *engine;
27
+ swift_port *port = NULL;
28
+
29
+ /* Open the Swift TTS Engine */
30
+ if ( (engine = swift_engine_open(NULL)) == NULL) {
31
+ fprintf(stderr, "Failed to open Swift Engine.");
32
+ goto all_done;
33
+ }
34
+ /* Open a Swift Port through which to make TTS calls */
35
+ if ( (port = swift_port_open(engine, NULL)) == NULL) {
36
+ fprintf(stderr, "Failed to open Swift Port.");
37
+ goto all_done;
38
+ }
39
+
40
+ /* Synthesize argument as a text string */
41
+ swift_port_speak_text(port, ctext, 0, NULL, NULL, NULL);
42
+
43
+ all_done:
44
+ /* Close the Swift Port and Engine */
45
+ if (NULL != port) swift_port_close(port);
46
+ if (NULL != engine) swift_engine_close(engine); return 1;
47
+ }
data/lib/extconf.rb ADDED
@@ -0,0 +1,14 @@
1
+ # Loads mkmf which is used to make makefiles for Ruby extensions
2
+ require 'mkmf'
3
+
4
+ #we need some extra libs from swift, needs to be installed, fix the path if it's somewhere else
5
+ $LOCAL_LIBS += " /opt/swift/lib/libswift.so"
6
+
7
+ # Give it a name
8
+ extension_name = 'swiftly'
9
+
10
+ # The destination
11
+ dir_config(extension_name)
12
+
13
+ # Do the work
14
+ create_makefile(extension_name)
@@ -0,0 +1,11 @@
1
+ require 'swiftly'
2
+ include Swiftly
3
+
4
+ class String
5
+ def to_speech
6
+ speak self
7
+ end
8
+ end
9
+
10
+ "Test. Test.".to_speech
11
+ #speak "Don't speak, I know just what you're thinking."
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pangdudu-swiftly
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - pangdudu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-17 00:00:00 -07:00
13
+ default_executable: swiftly
14
+ dependencies: []
15
+
16
+ description: swiftly!
17
+ email: pangdudu@github
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - lib/Swiftly.c
26
+ - lib/extconf.rb
27
+ - test/test_swiftly.rb
28
+ - external/include
29
+ - external/include/swift_exports.h
30
+ - external/include/swift_defs.h
31
+ - external/include/swift.h
32
+ - external/include/swift_params.h
33
+ - README.rdoc
34
+ has_rdoc: true
35
+ homepage: http://github.com/pangdudu/swiftly
36
+ licenses:
37
+ post_install_message:
38
+ rdoc_options: []
39
+
40
+ require_paths:
41
+ - lib
42
+ - external/include
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project: http://github.com/pangdudu/swiftly
58
+ rubygems_version: 1.3.5
59
+ signing_key:
60
+ specification_version: 2
61
+ summary: more swiftly!
62
+ test_files: []
63
+