Class: Bullfrog::TTS

Inherits:
Object
  • Object
show all
Defined in:
lib/bullfrog.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content.



34
35
36
# File 'lib/bullfrog.rb', line 34

def content
  @content
end

#errorObject

Returns the value of attribute error.



34
35
36
# File 'lib/bullfrog.rb', line 34

def error
  @error
end

#hashhObject

Returns the value of attribute hashh.



34
35
36
# File 'lib/bullfrog.rb', line 34

def hashh
  @hashh
end

#idObject

Returns the value of attribute id.



34
35
36
# File 'lib/bullfrog.rb', line 34

def id
  @id
end

#voice_idObject

Returns the value of attribute voice_id.



34
35
36
# File 'lib/bullfrog.rb', line 34

def voice_id
  @voice_id
end

Class Method Details

.convert(data) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/bullfrog.rb', line 41

def convert(data)
  tts = Bullfrog::TTS.new
  tts.content = data[:content]
  tts.voice_id = data[:voice_id]
  tts.save
  tts
end

.voicesObject

TODO: make this call out to the server



49
50
51
52
53
54
55
# File 'lib/bullfrog.rb', line 49

def voices
  [
      {id: 1, name: "Johnathon"},
      {id: 2, name: "Bob"},
      {id: 3, name: "Isaiah"}
  ]
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/bullfrog.rb', line 83

def complete?
  status == "complete"
end


86
87
88
89
# File 'lib/bullfrog.rb', line 86

def link
  return unless complete?
  "#{Bullfrog.base_uri}/conversions/#{@hashh}/download"
end

#saveObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/bullfrog.rb', line 57

def save
  options = {
      body: {
          conversion:{
              content: @content,
              voice_id: @voice_id
          }
      }
  }
  if @id
    options[:body][:id] = @id
    response = Bullfrog.put("/conversions/#{@id}", options)
  else
    response = Bullfrog.post("/conversions", options)
  end
  @id = response["id"]
  @hashh = response["hashh"]
  @error = response["error"]
  (@error.nil? or @error == "")
end

#statusObject



77
78
79
80
81
82
# File 'lib/bullfrog.rb', line 77

def status
  return unless @id
  response = Bullfrog.get "/conversions/#{@id}/status"
  status = response["status"]
  status
end