Skip to content
Merged
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
1 change: 0 additions & 1 deletion code/create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ def speech_config():
if response.status_code == 200:
return {
"token": response.text,
"key": speech_key,
"region": env_helper.AZURE_SPEECH_SERVICE_REGION,
"languages": env_helper.AZURE_SPEECH_RECOGNIZER_LANGUAGES,
}
Expand Down
4 changes: 2 additions & 2 deletions code/frontend/src/components/Answer/Answer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { conversationResponseWithCitations } from "../../../__mocks__/SampleData
jest.mock('microsoft-cognitiveservices-speech-sdk', () => {
return {
SpeechConfig: {
fromSubscription: jest.fn(),
fromAuthorizationToken: jest.fn(),
},
AudioConfig: {
fromDefaultSpeakerOutput: jest.fn(),
Expand Down Expand Up @@ -51,7 +51,7 @@ const speechMockData = {
jest.mock("microsoft-cognitiveservices-speech-sdk", () => {
return {
SpeechConfig: {
fromSubscription: jest.fn(),
fromAuthorizationToken: jest.fn(),
fromSpeakerOutput: jest.fn().mockReturnValue({}),
},
AudioConfig: {
Expand Down
22 changes: 11 additions & 11 deletions code/frontend/src/components/Answer/Answer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const Answer = ({
const [audioContext, setAudioContext] = useState<AudioContext | null>(null); //Manully manage the audio context eg pausing resuming

const [synthesizerData, setSynthesizerData] = useState({
key: "",
token: "",
region: "",
});
const [synthesizer, setSynthesizer] =
Expand All @@ -70,8 +70,8 @@ export const Answer = ({
};

const initializeSynthesizer = () => {
const speechConfig = sdk.SpeechConfig.fromSubscription(
synthesizerData.key,
const speechConfig = sdk.SpeechConfig.fromAuthorizationToken(
synthesizerData.token,
synthesizerData.region
);
const newAudioDestination = new SpeechSDK.SpeakerAudioDestination();
Expand All @@ -90,7 +90,7 @@ export const Answer = ({
};

useEffect(() => {
if (synthesizerData.key != "") {
if (synthesizerData.token != "") {
initializeSynthesizer();

return () => {
Expand All @@ -112,12 +112,12 @@ export const Answer = ({
const response = await fetch("/api/speech");
try {
if (!response.ok) {
throw new Error("Network response was not ok");
throw new Error("Network response was not ok");
}
const data = await response.json();
setSynthesizerData({ key: data.key, region: data.region });
} catch(e) {
console.log(e)
const data = await response.json();
setSynthesizerData({ token: data.token, region: data.region });
} catch (e) {
console.log(e);
}
};
fetchSythesizerData();
Expand Down Expand Up @@ -334,7 +334,7 @@ export const Answer = ({
}
data-testid="toggle-citations-list"
>
<Text className={styles.accordionTitle}>
<Text className={styles.accordionTitle}>
<span data-testid="no-of-references">
{parsedAnswer.citations.length > 1
? parsedAnswer.citations.length + " references"
Expand Down Expand Up @@ -375,7 +375,7 @@ export const Answer = ({
onKeyDown={(e) =>
e.key === " " || e.key === "Enter"
? onCitationClicked(citation)
: () => {}
: () => { }
}
tabIndex={0}
title={createCitationFilepath(citation, ++idx)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def test_speech_token_returned(app_url: str, app_config: AppConfig):
"token": "speech-token",
"region": app_config.get("AZURE_SPEECH_SERVICE_REGION"),
"languages": app_config.get("AZURE_SPEECH_RECOGNIZER_LANGUAGES").split(","),
"key": "some-azure-speech-service-key",
}
assert response.headers["Content-Type"] == "application/json"

Expand Down
2 changes: 0 additions & 2 deletions code/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def test_returns_speech_token_using_keys(
"token": "speech-token",
"region": AZURE_SPEECH_SERVICE_REGION,
"languages": AZURE_SPEECH_RECOGNIZER_LANGUAGES,
"key": "mock-speech-key",
}

requests.post.assert_called_once_with(
Expand Down Expand Up @@ -159,7 +158,6 @@ def test_returns_speech_token_using_rbac(
"token": "speech-token",
"region": AZURE_SPEECH_SERVICE_REGION,
"languages": AZURE_SPEECH_RECOGNIZER_LANGUAGES,
"key": "mock-key1",
}

requests.post.assert_called_once_with(
Expand Down