2018-09-03 15:24:43 +00:00
|
|
|
SPEECH = Speech.new(
|
|
|
|
creds: JSON.parse(File.read(ENV["STREAMING_CREDENTIALS"])),
|
|
|
|
host_lang: "en",
|
|
|
|
recieve_lang: "fr"
|
|
|
|
)
|
|
|
|
|
|
|
|
while true
|
|
|
|
SPEECH.stream
|
|
|
|
end
|
|
|
|
|
2018-08-29 13:09:12 +00:00
|
|
|
class ChatRoomsController < ApplicationController
|
|
|
|
|
2018-08-30 02:00:09 +00:00
|
|
|
def show
|
|
|
|
@chat_room = ChatRoom.find(params[:id])
|
|
|
|
end
|
|
|
|
|
2018-08-29 13:09:12 +00:00
|
|
|
def create
|
2018-08-30 17:42:42 +00:00
|
|
|
# HTTP status code 200 with an empty body
|
2018-09-03 15:24:43 +00:00
|
|
|
|
|
|
|
SPEECH.write_to_stream(params[:audio]) unless params[:audio].nil?
|
2018-08-29 13:09:12 +00:00
|
|
|
|
2018-08-30 17:42:42 +00:00
|
|
|
ActionCable.server.broadcast "chat_room_#{params[:room]}", session_params
|
2018-09-03 15:24:43 +00:00
|
|
|
|
|
|
|
head :no_content
|
2018-08-30 17:42:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def session_params
|
|
|
|
# SDP = Session description protocol (codec info from client)
|
|
|
|
# Candidate = ICE candidates (e.g. TURN and STUN server)
|
|
|
|
params.permit(:type, :from, :to, :sdp, :candidate, :room)
|
2018-08-29 13:09:12 +00:00
|
|
|
end
|
2018-09-03 15:24:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-29 13:09:12 +00:00
|
|
|
end
|
2018-09-03 15:24:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|