Skip to content

Commit 0f02fbf

Browse files
committed
ai hologram work
ai hologram work
1 parent 47e0d22 commit 0f02fbf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+6384
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
"env": {
3+
"es15": true,
4+
"node": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/recommended"
9+
],
10+
"overrides": [
11+
],
12+
"parser": "@typescript-eslint/parser",
13+
"parserOptions": {
14+
"ecmaVersion": "latest",
15+
"sourceType": "module"
16+
},
17+
"plugins": [
18+
"@typescript-eslint"
19+
],
20+
"rules": {
21+
},
22+
"exclude": ["node_modules"]
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
registry="https://registry.npmjs.org/"
2+
@types:registry="https://registry.npmjs.org/"
3+
strict-ssl=false
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import express from "express";
2+
import cors from "cors";
3+
import bodyParser from "body-parser";
4+
import * as common from "oci-common";
5+
import * as aispeech from "oci-aispeech";
6+
import https from 'https';
7+
import fs from 'fs';
8+
9+
const app = express();
10+
const port = 8448;
11+
12+
// SSL Certificate options with specified paths
13+
const options = {
14+
key: fs.readFileSync('C:\\aiholo-app\\localhost-key.pem'), // Path to your private key
15+
cert: fs.readFileSync('C:\\aiholo-app\\localhost.pem') // Path to your certificate
16+
};
17+
18+
// Configure CORS to allow requests from your specific client origin
19+
// app.use(cors({
20+
// origin: 'http://130.61.51.75:4884', // Adjust this to match the origin you are accessing the server from
21+
// credentials: true // Allows cookies and credentials to be sent along with the requests
22+
// }));
23+
24+
app.use(cors({
25+
origin: ['https://130.61.51.75:4884'],
26+
credentials: true,
27+
methods: ['GET', 'POST'],
28+
allowedHeaders: ['Content-Type', 'Authorization']
29+
}));
30+
31+
32+
// The OCID of the compartment for authentication and authorization
33+
const compartmentId = "ocid1.compartment.oc1..aaaaaaaafnah3ogykjsg34qruhixhb2drls6zhsejzm7mubi2i5qj66slcoq";
34+
35+
// Set the region for OCI services
36+
const region = "us-phoenix-1";
37+
const provider = new common.SessionAuthDetailProvider("C:/Users/opc/.oci/config", "MYSPEECHAIPROFILE");
38+
// const provider = new common.ConfigFileAuthenticationDetailsProvider("C:/Users/opc/.oci/config", "DEFAULT");
39+
40+
/**
41+
* Generates a real-time session token using Oracle Cloud Infrastructure (OCI) AI Speech Service.
42+
* Configures the OCI client with a specific region and compartment ID, then requests a real-time session token.
43+
*
44+
* @returns {Promise<string>} The real-time session token generated by the AI Speech Service.
45+
* @throws {Error} If the request to generate the session token fails.
46+
*/
47+
async function getRealtimeToken() {
48+
provider.setRegion(region);
49+
const speechClient = new aispeech.AIServiceSpeechClient({ authenticationDetailsProvider: provider });
50+
51+
const createRealtimeSessionTokenDetails = {
52+
compartmentId: compartmentId,
53+
};
54+
55+
const createRealtimeSessionTokenRequest: aispeech.requests.CreateRealtimeSessionTokenRequest = {
56+
createRealtimeSessionTokenDetails: createRealtimeSessionTokenDetails,
57+
};
58+
59+
const createRealtimeSessionTokenResponse = await speechClient.createRealtimeSessionToken(createRealtimeSessionTokenRequest);
60+
console.log("Token generated: ", createRealtimeSessionTokenResponse);
61+
return createRealtimeSessionTokenResponse.realtimeSessionToken;
62+
}
63+
64+
app.use(bodyParser.json());
65+
66+
app.get("/authenticate", async (req, res) => {
67+
try {
68+
const token = await getRealtimeToken();
69+
console.log("Token Response: ", token);
70+
res.send(token);
71+
} catch (error) {
72+
console.error("createRealtimeSessionToken Failed with error: ", error);
73+
res.status(500).send(error.toString());
74+
}
75+
});
76+
77+
app.get("/region", (req, res) => {
78+
console.log('Received headers:', req.headers);
79+
res.send({ region: region });
80+
});
81+
82+
// Using HTTPS server instead of the standard HTTP server
83+
https.createServer(options, app).listen(port, '0.0.0.0', () => {
84+
console.log(`https server running at https://0.0.0.0:${port}`);
85+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ignore": [
3+
"node_modules"
4+
]
5+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"watch": [
3+
"index.ts",
4+
"index.html"
5+
],
6+
"ext": ".ts,.js",
7+
"ignore": [],
8+
"exec": "npx ts-node ./index.ts"
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
registry="https://registry.npmjs.org/"
2+
@types:registry="https://registry.npmjs.org/"
3+
strict-ssl=false
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<meta name="theme-color" content="#000000" />
7+
<meta name="description" content="SDK Latency Testing Tool" />
8+
<link
9+
rel="stylesheet"
10+
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
11+
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
12+
crossorigin="anonymous" />
13+
<title>OCI AI Speech</title>
14+
<link rel="icon" href="https://www.oracle.com/asset/web/favicons/favicon-32.png" sizes="32x32" />
15+
<link rel="icon" href="https://www.oracle.com/asset/web/favicons/favicon-128.png" sizes="128x128" />
16+
<link rel="icon" href="https://www.oracle.com/asset/web/favicons/favicon-192.png" sizes="192x192" />
17+
<link rel="apple-touch-icon" href="https://www.oracle.com/asset/web/favicons/favicon-120.png" sizes="120x120" />
18+
<link rel="apple-touch-icon" href="https://www.oracle.com/asset/web/favicons/favicon-152.png" sizes="152x152" />
19+
<link rel="apple-touch-icon" href="https://www.oracle.com/asset/web/favicons/favicon-180.png" sizes="180x180" />
20+
</head>
21+
<body>
22+
<noscript>You need to enable JavaScript to run this app.</noscript>
23+
<div id="root"></div>
24+
<!--
25+
This HTML file is a template.
26+
If you open it directly in the browser, you will see an empty page.
27+
28+
You can add webfonts, meta tags, or analytics to this file.
29+
The build step will place the bundled scripts into the <body> tag.
30+
31+
To begin the development, run `npm start` or `yarn start`.
32+
To create a production bundle, use `npm run build` or `yarn build`.
33+
-->
34+
</body>
35+
</html>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *
3+
Disallow:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const express = require('express');
2+
const https = require('https');
3+
const fs = require('fs');
4+
const path = require('path');
5+
const app = express();
6+
7+
const PORT = 4884; // Port number for your HTTPS server
8+
const options = {
9+
key: fs.readFileSync('C:\\aiholo-app\\localhost-key.pem'), // Path to your private key
10+
cert: fs.readFileSync('C:\\aiholo-app\\localhost.pem') // Path to your certificate
11+
};
12+
13+
// Serve static files from the React build directory
14+
app.use(express.static(path.join(__dirname, 'build')));
15+
16+
// All routes should redirect to the index.html
17+
app.get('*', (req, res) => {
18+
res.sendFile(path.join(__dirname, 'build', 'index.html'));
19+
});
20+
21+
https.createServer(options, app).listen(PORT, () => {
22+
console.log(`Server running on https://130.61.51.75:${PORT}`);
23+
});

interactive-ai-holograms/STT-OCI-npm/react-client/src/App-goodbutnoquestionvalue.tsx0

Whitespace-only changes.

0 commit comments

Comments
 (0)