Parsing the gRPC LocationMetadata of a java google.cloud.speech.v2 listLocations request

22 Views Asked by At

I have registered a Google Speech project and can use it. Now I want to get the possible locations and get their capabilities (Kotlin code).

    val speechClient = SpeechClient.create()
    val listLocationsRequest = ListLocationsRequest.newBuilder()
        .setName("projects/$projectId")
        .build()

    for (page in speechClient.listLocations(listLocationsRequest).iteratePages()) {
        println("Found ${page.pageElementCount} entries on this page...")
        for (value in page.values) {
            println("  * Name: " + value.name)
            println("    LocationId: " + value.locationId)
            println("    DisplayName: " + value.displayName)
            println("    Labels: " + value.labelsMap)
            println("    Metadata: " + value.metadata)

I can access the metadata, but it looks like binary JSON.

I have found that there is a LocationMetadata.parser() but it fails with a ton of 'UNKNOWN_ENUM_VALUE_Environment_???':

            val parser = LocationMetadata.parser()
            val metadata = parser.parseFrom(value.metadata.value)
            println("    Metadata: $metadata")

Has anyone solved this already? Thanks

0

There are 0 best solutions below