Skip to content

Commit

Permalink
Merge pull request #436 from classtranscribe/DontCreateEmptyDescriptions
Browse files Browse the repository at this point in the history
Do not create empty descriptions. Update MS Speech Reconigition
  • Loading branch information
angrave authored Jan 12, 2024
2 parents ce0ac10 + f4ea72c commit 5ff6e70
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 6 deletions.
File renamed without changes.
16 changes: 15 additions & 1 deletion TaskEngine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,21 @@ RUN dotnet publish TaskEngine.csproj -c Release -o /app --no-restore

FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim as publish_base
# FROM mcr.microsoft.com/dotnet/core/runtime:3.1.3-bionic as publish_base
RUN apt-get update && apt-get install -y build-essential libasound2 wget netcat-traditional && apt-get -q update
# Install prerequisites for Azure Speech Services: build-essential libssl-dev ca-certificates libasound2 wget
# See https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/quickstarts/setup-platform

RUN apt-get update && apt-get install -y build-essential libssl-dev ca-certificates libasound2 wget && \
apt-get install -y netcat-traditional && apt-get -q update

# Microsoft 8.0 issue: https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/2204
# This will install OpenSSL 1.1.1 because it is needed by the Speech SDK.
RUN \
wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb && \
wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1f-1ubuntu2.20_amd64.deb && \
dpkg -i libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb && \
dpkg -i libssl-dev_1.1.1f-1ubuntu2.20_amd64.deb && \
rm libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb libssl-dev_1.1.1f-1ubuntu2.20_amd64.deb


FROM publish_base as publish
WORKDIR /
Expand Down
4 changes: 4 additions & 0 deletions TaskEngine/Tasks/DescribeImageTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ async Task<string> DescribeImage(string imagePath, string ocrtext) {
p.Close();
p.Dispose();
GetLogger().LogInformation($"{imagePath} - Returning. Description:<<{output}>>");
if(output.Length == 0)
{
throw new Exception($"{imagePath} - Ignoring empty description");
}
return output;
}
}
Expand Down
10 changes: 10 additions & 0 deletions TestAzureCognitiveServices/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.vs
**/.vscode
**/*.*proj.user
**/charts
**/bin
**/obj
3 changes: 2 additions & 1 deletion TestAzureCognitiveServices/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ static void Main(string[] args)
}

async static Task<string> useAzureTranslationAsync() {
var defaultKeys = "hexvalue,northcentralus";
var defaultKeys = "996885bc424b4fda9df983c404e7309c,westus";
Console.WriteLine($"Environment variable AZURE_SUBSCRIPTION_KEYS=key,region;...");
var keys = System.Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_KEYS") ?? defaultKeys;

Expand All @@ -162,6 +162,7 @@ async static Task<string> useAzureTranslationAsync() {

SpeechTranslationConfig speechConfig = SpeechTranslationConfig.FromSubscription(key, region);
speechConfig.RequestWordLevelTimestamps();
speechConfig.SetProperty(PropertyId.Speech_LogFilename, "Logfile.txt");

speechConfig.SpeechRecognitionLanguage = "en-US";

Expand Down
29 changes: 25 additions & 4 deletions TestAzureCognitiveServices/TestAzure.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
FROM mcr.microsoft.com/dotnet/core/sdk:3.1.201-bionic as build1
FROM mcr.microsoft.com/dotnet/sdk:8.0.100-1-bookworm-slim as build1

WORKDIR /src/TestAzureCognitiveServices

COPY . .
RUN dotnet restore ./TestAzureCognitiveServices.csproj
RUN dotnet publish ./TestAzureCognitiveServices.csproj -c Release -o /app --no-restore

FROM mcr.microsoft.com/dotnet/core/runtime:3.1.3-bionic as publish_base1
#RUN apt-get -q update
FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim as publish_base1

# Grrr AzureServices does not work on dotnet8 on Debian 12 because it wont link to libssl3 - fix below is needed for short-term

# Install prerequisites for Azure Speech Services
# See https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/quickstarts/setup-platform
RUN apt-get update
RUN apt-get -y install build-essential libssl-dev libasound2 wget

# Microsoft 8.0 issue: https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/2204
# This will install OpenSSL 1.1.1 because it is needed by the Speech SDK.
RUN \
wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb && \
wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1f-1ubuntu2.20_amd64.deb && \
dpkg -i libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb && \
dpkg -i libssl-dev_1.1.1f-1ubuntu2.20_amd64.deb && \
rm libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb libssl-dev_1.1.1f-1ubuntu2.20_amd64.deb





FROM publish_base1 as publish1
WORKDIR /app
Expand All @@ -17,4 +36,6 @@ CMD ["dotnet", "/app/TestAzureCognitiveServices.dll"]

# Example
#docker build -t azuretest -f TestAzure.Dockerfile .
#docker run -t azuretest ls
#docker run -t azuretest ls
# [690371]: 31ms SPX_TRACE_ERROR: AZ_LOG_ERROR: shim_openssl.c:55 libssl could not be loaded
# [690371]: 31ms SPX_TRACE_ERROR: AZ_LOG_ERROR: tlsio_openssl.c:2175 Could not load libssl

0 comments on commit 5ff6e70

Please sign in to comment.