Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real-time speech to text #275

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/switch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
[
{
"identifier": "switch-staging",
"branch": "develop",
"branch": "speech_to_text",
"image_tag": "staging",
"ecs_service": "switch-staging",
"ecs_cluster": "somleng-switch-staging"
Expand Down
4 changes: 4 additions & 0 deletions components/freeswitch/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FROM drachtio/drachtio-freeswitch-base as build

FROM debian:bullseye-slim

ARG signalwire_token
Expand Down Expand Up @@ -61,6 +63,8 @@ RUN chown -R freeswitch:daemon /etc/freeswitch
RUN touch /var/log/freeswitch/freeswitch.log
RUN chown freeswitch:freeswitch /var/log/freeswitch/freeswitch.log

COPY --from=build /usr/local/freeswitch/mod/mod_aws_transcribe.* /usr/lib/freeswitch/mod/

# Install the entrypoint script
COPY docker-entrypoint.sh /docker-entrypoint.sh

Expand Down
2 changes: 2 additions & 0 deletions components/freeswitch/conf/autoload_configs/modules.conf.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<configuration name="modules.conf" description="Modules">
<modules>
<load module="mod_aws_transcribe"/>

<!-- Loggers -->
<load module="mod_console"/>

Expand Down
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions components/freeswitch_event_logger/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ func main() {
// Filters
evFilters := make(map[string][]string)
evFilters["Event-Name"] = append(evFilters["Event-Name"], "HEARTBEAT")
evFilters["Event-Name"] = append(evFilters["Event-Name"], "CUSTOM")

evHandlers := map[string][]func(string, int){
"HEARTBEAT": {logHeartbeat},
"CUSTOM": {logHeartbeat},
}

event_socket_host := os.Getenv("EVENT_SOCKET_HOST")
Expand Down
51 changes: 50 additions & 1 deletion infrastructure/modules/somleng_switch/switch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,49 @@ resource "aws_iam_user_policy" "recordings" {
EOF
}

# Custom FreeSWITCH modules user
resource "aws_iam_user" "fs_modules" {
name = "${var.switch_identifier}_fs_modules"
}

resource "aws_iam_access_key" "fs_modules" {
user = aws_iam_user.fs_modules.name
}


resource "aws_iam_user_policy" "fs_modules" {
name = aws_iam_user.fs_modules.name
user = aws_iam_user.fs_modules.name

policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"transcribe:StartStreamTranscription",
"transcribe:StartStreamTranscriptionWebSocket"
],
"Resource": "*"
}
]
}
EOF
}

resource "aws_ssm_parameter" "fs_modules_access_key_id" {
name = "somleng-switch.${var.app_environment}.fs_modules_access_key_id"
type = "SecureString"
value = aws_iam_access_key.fs_modules.id
}

resource "aws_ssm_parameter" "fs_modules_secret_access_key" {
name = "somleng-switch.${var.app_environment}.fs_modules_secret_access_key"
type = "SecureString"
value = aws_iam_access_key.fs_modules.secret
}

# IAM
data "aws_iam_policy_document" "ecs_task_assume_role_policy" {
version = "2012-10-17"
Expand Down Expand Up @@ -260,7 +303,9 @@ resource "aws_iam_policy" "task_execution_custom_policy" {
"${aws_ssm_parameter.freeswitch_event_socket_password.arn}",
"${var.json_cdr_password_parameter_arn}",
"${aws_ssm_parameter.recordings_bucket_access_key_id.arn}",
"${aws_ssm_parameter.recordings_bucket_secret_access_key.arn}"
"${aws_ssm_parameter.recordings_bucket_secret_access_key.arn}",
"${aws_ssm_parameter.fs_modules_access_key_id.arn}",
"${aws_ssm_parameter.fs_modules_secret_access_key.arn}"
]
}
]
Expand Down Expand Up @@ -405,6 +450,10 @@ data "template_file" "switch" {
recordings_bucket_secret_access_key_parameter_arn = aws_ssm_parameter.recordings_bucket_secret_access_key.arn
recordings_bucket_region = aws_s3_bucket.recordings.region

fs_modules_access_key_id_parameter_arn = aws_ssm_parameter.fs_modules_access_key_id.arn
fs_modules_secret_access_key_parameter_arn = aws_ssm_parameter.fs_modules_secret_access_key.arn
aws_transcribe_region = "us-east-1"

services_function_arn = aws_lambda_function.services.arn
}
}
Expand Down
16 changes: 16 additions & 0 deletions infrastructure/modules/somleng_switch/templates/switch.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@
{
"name": "FS_EVENT_SOCKET_PASSWORD",
"valueFrom": "${freeswitch_event_socket_password_parameter_arn}"
},
{
"name": "AWS_ACCESS_KEY_ID",
"valueFrom": "${fs_modules_access_key_id_parameter_arn}"
},
{
"name": "AWS_SECRET_ACCESS_KEY",
"valueFrom": "${fs_modules_secret_access_key_parameter_arn}"
}
],
"portMappings": [
Expand All @@ -158,6 +166,14 @@
"name": "AWS_DEFAULT_REGION",
"value": "${region}"
},
{
"name": "AWS_TRANSCRIBE_REGION",
"value": "${aws_transcribe_region}"
},
{
"name": "AWS_REGION",
"value": "${aws_transcribe_region}"
},
{
"name": "FS_CACHE_DIRECTORY",
"value": "${cache_directory}"
Expand Down