Skip to content

Commit

Permalink
Reuse env var
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdiridho committed Jul 20, 2024
1 parent 6a177f2 commit 3a4c105
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ jobs:

- name: Deploy static site to S3 bucket
run: |
touch .env
echo VITE_AWS_REGION=${{ secrets.AWS_REGION }} >> .env
echo VITE_QUEUE_URL=${{ secrets.QUEUE_URL }} >> .env
echo VITE_FUNCTION_NAME=${{ secrets.FUNCTION_NAME }} >> .env
echo VITE_IDENTITY_POOL=${{ secrets.IDEDNTITY_POOL_ID }} >> .env
echo VITE_BATCH_BUCKET=${{ secrets.S3_BATCH_BUCKET }} >> .env
npm install
npm run build
pushd dist
aws s3 sync . s3://audioctxai.com --delete --sse AES256 --cache-control no-cache
popd
rm -rf node_modules package-log.json dist
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
QUEUE_URL: ${{ secrets.QUEUE_URL }}
FUNCTION_NAME: ${{ secrets.FUNCTION_NAME }}
IDENTITY_POOL: ${{ secrets.IDENTITY_POOL }}
BATCH_BUCKET: ${{ secrets.BATCH_BUCKET }}
7 changes: 7 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const envConfig = {
AWS_REGION: import.meta.env.VITE_AWS_REGION,
QUEUE_URL: import.meta.env.VITE_QUEUE_URL,
FUNCTION_NAME: import.meta.env.VITE_FUNCTION_NAME,
IDENTITY_POOL: import.meta.env.VITE_IDEDNTITY_POOL_ID,
BATCH_BUCKET: import.meta.env.VITE_S3_BATCH_BUCKET
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"start": "vite --port 8081 --open /",
"start:build": "vite dist --port 8081 --open /",
"build": "vite build; cp -rf images recorder-worklet.js RecorderPCM* dist"
"build": "vite build; cp -rf images config.js recorder-worklet.js RecorderPCM* dist"
},
"keywords": [
"aws",
Expand Down
18 changes: 10 additions & 8 deletions src/comm-ai.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import { PollyClient, SynthesizeSpeechCommand } from "@aws-sdk/client-polly";
import { LambdaClient, InvokeCommand } from "@aws-sdk/client-lambda";
import { SQSClient, ReceiveMessageCommand, DeleteMessageCommand } from "@aws-sdk/client-sqs";
import { Buffer } from "buffer";
import { RecorderPCM } from '../RecorderPCM'; // using the audio worklet
import { RecorderPCMSPN } from '../RecorderPCMScriptNode'; // using the script processor node
import { RecorderPCM } from "../RecorderPCM"; // using the audio worklet
import { RecorderPCMSPN } from "../RecorderPCMScriptNode"; // using the script processor node
import { envConfig } from "../config";
import MicrophoneStream from "microphone-stream";

const AWS_REGION = "<AWS_REGION>";
const QUEUE_URL = "<QUEUE_URL>";
const FUNCTION_NAME = "<FUNCTION_NAME>";
const IDENTITY_POOL = "<IDEDNTITY_POOL_ID>";
const BATCH_BUCKET = "<S3_BATCH_BUCKET>";
console.log('AWS_REGION', import.meta.env)
const AWS_REGION = envConfig.AWS_REGION;
const QUEUE_URL = envConfig.QUEUE_URL;
const FUNCTION_NAME = envConfig.FUNCTION_NAME;
const IDENTITY_POOL = envConfig.IDEDNTITY_POOL;
const BATCH_BUCKET = envConfig.BATCH_BUCKET;

const SAMPLE_RATE = 48000;
const voices = {
Expand Down Expand Up @@ -461,7 +463,7 @@ class CommAi extends LitElement {
LanguageCode: "id-ID",
MediaFormat: "wav",
Media: {
MediaFileUri: "https://BATCH_BUCKET.s3-<AWS_REGION>.amazonaws.com/idID.wav",
MediaFileUri: `https://${BATCH_BUCKET}.s3-${AWS_REGION}.amazonaws.com/idID.wav`,
},
OutputBucketName: BATCH_BUCKET
}));
Expand Down

0 comments on commit 3a4c105

Please sign in to comment.