Discussions
related driver_expressions
11 months ago by vebreuzavigei-3477
when I tried to hit "https://api.d-id.com/talks/streams/{id}" API for the result_url and streaming also. but didn't see any expressions. here is the below code
async function callingCreatePeer(query) {
var user_c_data = jQuery(".chat-main-container").attr("user_c");
console.log(user_c_data);
console.log("dhfghdh", DID_API.video_status_val);
console.log("DID_API.user_credits", DID_API.user_credits);
console.log("user_c_data", user_c_data);
var video_status = jQuery('#videoToggle').attr('data-status');
if (
DID_API.meta_video_status == "on" &&
video_status === "on" &&
DID_API.user_credits > 0 &&
user_c_data > 0
) {
console.log("i am here");
if (
peerConnection?.signalingState === "stable" ||
peerConnection?.iceConnectionState === "connected"
) {
try {
console.log(`${streamId}`);
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// Example: Generate a random number between 1 and 100000000000000000000
var randomNumber = getRandomInt(1, 100000000000000000000);
/* working aws start*/
AWS.config.update({
region: DID_API.region,
accessKeyId: DID_API.accessKeyId,
secretAccessKey: DID_API.secretAccessKey,
});
var s3 = new AWS.S3();
var current_user = jQuery(".chat-title").attr("current-user");
var params = {
Bucket: DID_API.Bucket_name,
Key: "assets/avatars_videos/"+current_user+"/avatar_" + randomNumber + ".mp4",
};
var result_pre_url = s3.getSignedUrl("putObject", params);
console.log(result_pre_url);
// &X-Amz-SignedHeaders=host
// return;
/* working aws end*/
const talkResponse = await fetchWithRetries(
`${DID_API.url}/talks/streams/${streamId}`,
{
method: "POST",
headers: {
Authorization: `Basic ${DID_API.key}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
script: {
type: "text",
subtitle: false,
provider: {
type: "microsoft",
voice_id: DID_API.voice_id,
},
ssml: false,
input: await query,
},
config: {
driver_expressions: {
expressions: [
{
start_frame: 0,
expression: "serious",
intensity: 1.0
},
],
transition_frames: 20
},
},
session_id: sessionId,
result_url: result_pre_url,
}),
}
);
const responseBody = await talkResponse.json(); // Parse the JSON response
console.log(JSON.stringify(responseBody));
var result_pre_url_get1 = s3.getSignedUrl("getObject", params);
// Parse the signed URL
const parsedUrl = new URL(result_pre_url_get1);
// Create a new URL without the query string
var objectUrlWithoutQueryString = `${parsedUrl.protocol}//${parsedUrl.host}${parsedUrl.pathname}`;
// Log the URL without the query string
console.log(
"Object URL without query string:",
objectUrlWithoutQueryString
);
if (talkResponse.status === 400) {
var error = new Error("Connection Lost.");
throw error;
}
console.log(talkResponse);
if (talkResponse.ok) {
return objectUrlWithoutQueryString;
}
if (!talkResponse.ok) {
throw error;
}
} catch (error) {
console.log("error in video api request");
throw error;
}
}
}
}